diff options
author | Radoslaw Czerski <r.czerski@samsung.com> | 2016-01-30 15:27:40 +0100 |
---|---|---|
committer | Radoslaw Czerski <r.czerski@samsung.com> | 2016-01-30 15:27:40 +0100 |
commit | cb34bcde063b7395f9caf5867384eec0af8eb4d3 (patch) | |
tree | 11cde00f3dcf82551cea97396dff6e934f5ad6ad | |
parent | cf5ac9c0a70f47d60c53123b29c46f918c39ec8d (diff) | |
download | share-panel-cb34bcde063b7395f9caf5867384eec0af8eb4d3.tar.gz share-panel-cb34bcde063b7395f9caf5867384eec0af8eb4d3.tar.bz2 share-panel-cb34bcde063b7395f9caf5867384eec0af8eb4d3.zip |
File paths retrieving fixed.
Change-Id: I3edf70a45b838ed29b9d4fa3933b678f5d4cab89
Signed-off-by: Radoslaw Czerski <r.czerski@samsung.com>
-rw-r--r-- | inc/conf.h | 2 | ||||
-rw-r--r-- | inc/utils.h | 30 | ||||
-rw-r--r-- | src/grid.c | 9 | ||||
-rw-r--r-- | src/page.c | 15 | ||||
-rw-r--r-- | src/share_panel.c | 13 | ||||
-rw-r--r-- | src/ui_manager.c | 8 | ||||
-rw-r--r-- | src/utils.c | 44 | ||||
-rw-r--r-- | tizen-manifest.xml | 10 |
8 files changed, 109 insertions, 22 deletions
@@ -40,7 +40,5 @@ #define PROJECT "share-panel" #define PACKAGE "org.tizen.share-panel" -#define LOCALEDIR "res/locale" -#define EDJEDIR "res/edje" #endif /* __TIZEN_SHARE_PANEL_CONF_H__ */ diff --git a/inc/utils.h b/inc/utils.h new file mode 100644 index 0000000..7ce3b65 --- /dev/null +++ b/inc/utils.h @@ -0,0 +1,30 @@ +/* + * 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 UTILS_H_ +#define UTILS_H_ + +/** + * @param sub_path sub path in res/ folder + * + * @return Absolute path for sub_path + * @remarks The returned path should be released. + */ + +char *utils_get_res_file_path(char *sub_path); + + +#endif /* UTILS_H_ */ @@ -24,6 +24,7 @@ #include "conf.h" #include "grid.h" #include "log.h" +#include "utils.h" #define PRIVATE_DATA_KEY_ITEM_INFO "pdkii" @@ -60,7 +61,7 @@ static char *__text_get(void *data, Evas_Object *obj, const char *part) return NULL; } -#define FILE_ITEM_EDJ EDJEDIR"/item.edj" + static Evas_Object *__add_icon(Evas_Object *parent, const char *file) { const char *real_icon_file = NULL; @@ -92,13 +93,17 @@ static Evas_Object *__add_icon(Evas_Object *parent, const char *file) icon_layout = elm_layout_add(parent); retv_if(!icon_layout, NULL); - elm_layout_file_set(icon_layout, FILE_ITEM_EDJ, "grid,icon"); + char *edj_path = utils_get_res_file_path("edje/item.edj"); + + elm_layout_file_set(icon_layout, edj_path, "grid,icon"); evas_object_size_hint_weight_set(icon_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(icon_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_show(icon_layout); elm_object_part_content_set(icon_layout, "icon", icon); + free(edj_path); + return icon_layout; } @@ -20,19 +20,22 @@ #include "conf.h" #include "log.h" #include "page.h" +#include "utils.h" - - -#define PAGE_EDJE_FILE EDJEDIR"/page.edj" Evas_Object *_page_create(Evas_Object *scroller, int page_width, int page_height) { Evas_Object *page = NULL; Evas_Object *page_bg = NULL; Evas *e = NULL; + char *edj_path = utils_get_res_file_path("edje/page.edj"); + page = elm_layout_add(scroller); - retv_if(!page, NULL); - elm_layout_file_set(page, PAGE_EDJE_FILE, "page"); + if(!page) { + free(edj_path); + return NULL; + } + elm_layout_file_set(page, edj_path, "page"); e = evas_object_evas_get(scroller); goto_if(!e, ERROR); @@ -48,9 +51,11 @@ Evas_Object *_page_create(Evas_Object *scroller, int page_width, int page_height elm_object_part_content_set(page, "bg", page_bg); evas_object_show(page); + free(edj_path); return page; ERROR: + free(edj_path); _page_destroy(page); return NULL; } diff --git a/src/share_panel.c b/src/share_panel.c index 1d1c054..2f8ef93 100644 --- a/src/share_panel.c +++ b/src/share_panel.c @@ -29,6 +29,7 @@ #include "ui_manager.h" #include "log.h" #include "scroller.h" +#include "utils.h" #ifdef EAPI #undef EAPI @@ -155,10 +156,15 @@ EAPI int share_panel_create(app_control_h control, share_panel_h *share_panel) retv_if(!share_panel, SHARE_PANEL_ERROR_INVALID_PARAMETER); retv_if(!control, SHARE_PANEL_ERROR_INVALID_PARAMETER); - bindtextdomain(SHARE_PANEL_DOMAIN, LOCALEDIR); + char *locale_path = utils_get_res_file_path("locale"); + + bindtextdomain(SHARE_PANEL_DOMAIN, locale_path); panel = calloc(1, sizeof(share_panel_s)); - retv_if(!panel, SHARE_PANEL_ERROR_NOT_INITIALIZED); + if(!panel) { + free(locale_path); + return SHARE_PANEL_ERROR_NOT_INITIALIZED; + } app_control_export_as_bundle(control, &(panel->b)); @@ -182,6 +188,8 @@ EAPI int share_panel_create(app_control_h control, share_panel_h *share_panel) *share_panel = panel; + free(locale_path); + return SHARE_PANEL_ERROR_NONE; ERROR: @@ -189,6 +197,7 @@ ERROR: _ui_manager_destroy(panel->ui_manager); } free(panel); + free(locale_path); return SHARE_PANEL_ERROR_NOT_INITIALIZED; } diff --git a/src/ui_manager.c b/src/ui_manager.c index 2bed036..993463d 100644 --- a/src/ui_manager.c +++ b/src/ui_manager.c @@ -31,8 +31,8 @@ #include "scroller.h" #include "conf.h" #include "ui_manager.h" +#include "utils.h" -#define FILE_LAYOUT_EDJ EDJEDIR"/layout.edj" #define GROUP_LAYOUT "layout" @@ -166,7 +166,9 @@ Evas_Object *_ui_manager_create(share_panel_s *share_panel) ui_manager = elm_layout_add(share_panel->win); retv_if(!ui_manager, NULL); - elm_layout_file_set(ui_manager, FILE_LAYOUT_EDJ, GROUP_LAYOUT); + char *edj_path = utils_get_res_file_path("edje/layout.edj"); + + elm_layout_file_set(ui_manager, edj_path, 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, EVAS_HINT_FILL); evas_object_show(ui_manager); @@ -245,9 +247,11 @@ Evas_Object *_ui_manager_create(share_panel_s *share_panel) edje_object_message_signal_process(edje); + free(edj_path); return ui_manager; ERROR: + free(edj_path); _ui_manager_destroy(ui_manager); return NULL; } diff --git a/src/utils.c b/src/utils.c new file mode 100644 index 0000000..e1a810a --- /dev/null +++ b/src/utils.c @@ -0,0 +1,44 @@ +/* + * 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_common.h> +#include <stdlib.h> +#include <string.h> +#include <stdio.h> + +#include "log.h" + + +char *utils_get_res_file_path(char *sub_path) +{ + char *res_path = app_get_resource_path(); + if(!res_path) + return NULL; + + size_t absolute_path_size = strlen(res_path) + strlen(sub_path) + 2; + + char *absolute_path = malloc(absolute_path_size); + if(!absolute_path) { + free(res_path); + return NULL; + } + + snprintf(absolute_path, (int)absolute_path_size, "%s%s", res_path, sub_path); + + free(res_path); + + return absolute_path; +} diff --git a/tizen-manifest.xml b/tizen-manifest.xml index b4ede5f..fa39edc 100644 --- a/tizen-manifest.xml +++ b/tizen-manifest.xml @@ -1,17 +1,9 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <manifest xmlns="http://tizen.org/ns/packages" api-version="3.0" install-location="internal-only" package="org.tizen.share-panel" version="1.0.0"> <profile name="mobile"/> - <ui-application appid="org.tizen.share-panel" exec="share-panel" hw-acceleration="on" launch_mode="group" multiple="false" nodisplay="true" type="capp"> + <ui-application appid="org.tizen.share-panel" exec="share-panel" hw-acceleration="on" launch_mode="group" multiple="true" nodisplay="false" type="capp"> <label>share-panel</label> <icon>share-panel.png</icon> - <app-control> - <mime name="*/*"/> - <operation name="http://tizen.org/appcontrol/operation/share"/> - </app-control> - <app-control> - <operation name="http://tizen.org/appcontrol/operation/multi_share"/> - <mime name="*/*"/> - </app-control> </ui-application> <privileges> <privilege>http://tizen.org/privilege/packagemanager.info</privilege> |