diff options
Diffstat (limited to 'main/src/control')
-rwxr-xr-x | main/src/control/ivug-context.c | 364 | ||||
-rwxr-xr-x | main/src/control/ivug-context.h | 71 | ||||
-rwxr-xr-x | main/src/control/ivug-crop-ug.cpp | 142 | ||||
-rwxr-xr-x | main/src/control/ivug-crop-ug.h | 44 | ||||
-rwxr-xr-x | main/src/control/ivug-detail-info.c | 703 | ||||
-rwxr-xr-x | main/src/control/ivug-detail-info.h | 85 | ||||
-rwxr-xr-x | main/src/control/ivug-filter.c | 161 | ||||
-rwxr-xr-x | main/src/control/ivug-filter.h | 41 | ||||
-rwxr-xr-x | main/src/control/ivug-popup.c | 643 | ||||
-rwxr-xr-x | main/src/control/ivug-popup.h | 82 | ||||
-rwxr-xr-x | main/src/control/ivug-selectioninfo.c | 151 | ||||
-rwxr-xr-x | main/src/control/ivug-selectioninfo.h | 33 | ||||
-rwxr-xr-x | main/src/control/ivug-setas.cpp | 321 | ||||
-rwxr-xr-x | main/src/control/ivug-setas.h | 42 | ||||
-rwxr-xr-x | main/src/control/ivug-widget.c | 215 | ||||
-rwxr-xr-x | main/src/control/ivug-widget.h | 61 |
16 files changed, 3159 insertions, 0 deletions
diff --git a/main/src/control/ivug-context.c b/main/src/control/ivug-context.c new file mode 100755 index 0000000..d6b8b95 --- /dev/null +++ b/main/src/control/ivug-context.c @@ -0,0 +1,364 @@ +/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.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 "ivug-common.h" +#include "ivug-util.h" + +#include "ivug-db.h" + +#include <ui-gadget-module.h> // ug_destroy_me +#include "ivug-context.h" + +#define MAX_INSTALNCE (5) + +typedef struct +{ + ui_gadget_h ug; // ug handle + + Evas_Object *parent_win; +// EFL theme + Elm_Theme *th; + +// Window Geometry + int win_w, win_h; //size + int rot; //window rotation value ( 0~360 ) + + callback_handle_t *callback_handle; + +} AppData; + +static Eina_List *ContextList = NULL; + +Elm_Theme* +gGetSystemTheme(void) +{ + AppData *ugContext; + ugContext = eina_list_data_get(ContextList); + + IV_ASSERT(ugContext != NULL); + + return ugContext->th; +} + +void +gGetSystemDimension(int *w, int *h) +{ + AppData *ugContext; + ugContext = eina_list_data_get(ContextList); + + IV_ASSERT(ugContext != NULL); + IV_ASSERT(w != NULL); + IV_ASSERT(h != NULL); + + *w = ugContext->win_w; + *h = ugContext->win_h; +} + + +void +gSetRotationDegree(int degree) +{ + AppData *ugContext; + ugContext = eina_list_data_get(ContextList); + + IV_ASSERT(ugContext != NULL); + + ugContext->rot = degree; +} + + + +int +gGetRotationDegree(void) +{ +#if 0 + AppData *ugContext; + ugContext = eina_list_data_get(ContextList); + + IV_ASSERT(ugContext != NULL); + + return ugContext->rot; +#else + return elm_win_rotation_get(ug_get_window()); +#endif + +} + +int gGetScreenWidth() +{ + AppData *ugContext; + ugContext = eina_list_data_get(ContextList); + + IV_ASSERT(ugContext != NULL); + + return ugContext->win_w; + +} + +int gGetScreenHeight() +{ + AppData *ugContext; + ugContext = eina_list_data_get(ContextList); + + IV_ASSERT(ugContext != NULL); + + return ugContext->win_h; + +} + +ui_gadget_h +gGetUGHandle(void) +{ + AppData *ugContext; + ugContext = eina_list_data_get(ContextList); + + IV_ASSERT(ugContext != NULL); + + MSG_IMAGEVIEW_HIGH("Get ug handle = 0x%08x", ugContext->ug); + + return ugContext->ug; +} + +Evas_Object * +gGetCurrentWindow(void) +{ + AppData *ugContext; + ugContext = eina_list_data_get(ContextList); + + IV_ASSERT(ugContext != NULL); + + MSG_IMAGEVIEW_HIGH("Get ug handle = 0x%08x", ugContext->ug); + + return ugContext->parent_win; +} + +callback_handle_t * +gGetCallbackHandle(void) +{ + AppData *ugContext; + ugContext = eina_list_data_get(ContextList); + + IV_ASSERT(ugContext != NULL); + + return ugContext->callback_handle; +} + + +#define IVUG_NAVIFRAME_NAME EDJ_PATH"/ivug-naviframe.edj" +#define IVUG_TOOLBAR_NAME EDJ_PATH"/ivug-toolbar.edj" +#define IVUG_BUTTON_NAME EDJ_PATH"/ivug-button.edj" +#define IVUG_SELECTION_INFO_NAME EDJ_PATH"/ivug-selectioninfo.edj" +#define IVUG_GENLIST EDJ_PATH"/ivug-genlist.edj" +#define IVUG_GENGRID EDJ_PATH"/ivug-gengrid.edj" + +static char *edj[] = { + IVUG_NAVIFRAME_NAME, + IVUG_TOOLBAR_NAME, + IVUG_BUTTON_NAME, + IVUG_SELECTION_INFO_NAME, + IVUG_GENLIST, + IVUG_GENGRID, + NULL, +}; + +bool +ivug_context_init(ui_gadget_h ug) +{ + AppData *Context = malloc(sizeof(AppData)); + if(Context == NULL) + { + MSG_IVUG_ERROR("Cannot allock memory"); + return false; + } + + Context->ug = ug; + Context->parent_win = ug_get_window(); + + if ( Context->parent_win ) + { + Context->rot = elm_win_rotation_get(Context->parent_win); + } + else + { + MSG_IMAGEVIEW_WARN("Cannot get parent window. rotation angle set as 0"); + Context->rot = 0; + } + +//get window width, height + int w, h; + + evas_object_geometry_get(Context->parent_win, NULL, NULL, &w, &h); + MSG_IMAGEVIEW_HIGH("Screen WH(%dx%d)", w, h); +// ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h); + Context->win_w = w; + Context->win_h = h; + + int i = 0; + + Context->th = elm_theme_new(); + + IV_ASSERT(Context->th != NULL); + + elm_theme_ref_set(Context->th, NULL); + + for ( i = 0; edj[i] != NULL; i++) + { + elm_theme_extension_add(Context->th, edj[i]); + } + + ContextList = eina_list_prepend(ContextList, Context); + + MSG_IVUG_HIGH("Append to list. Context=0x%08x", Context); + +#ifdef USE_NEW_DB_API + ivug_db_create(); +#endif + + Context->callback_handle = ivug_callback_register(); + if(Context->callback_handle == NULL) + { + MSG_IVUG_ERROR("ivug_callback_register error"); + goto ERROR; + } + + bindtextdomain(IVUG_TEXT_DOMAIN, IVUG_LOCALEDIR); //bind text domain + return TRUE; + +/**** Error routine ****/ +ERROR: + + if(Context->callback_handle) + { + ivug_callback_unregister(Context->callback_handle); + } + +#ifdef USE_NEW_DB_API + ivug_db_destroy(); +#endif + + Context = eina_list_data_get(ContextList); + ContextList = eina_list_remove_list(ContextList, ContextList); + + if(Context->th) + { + int i = 0; + for ( i = 0; edj[i] != NULL; i++) + { + elm_theme_extension_del(Context->th, edj[i]); + } + + elm_theme_free(Context->th); + } + + MSG_IVUG_HIGH("Remove from list. Context=0x%08x, ug=0x%08x", Context, Context->ug); + + free(Context); + + return false; +} + + +bool +ivug_context_deinit(ui_gadget_h ug) +{ + AppData *Context; + + Eina_List *l = NULL; + Eina_List *l_next = NULL; + + EINA_LIST_FOREACH_SAFE(ContextList, l, l_next, Context) + { + if(Context == NULL) + { + MSG_SDATA_ERROR("Context is NULL"); + return false; + } + if (Context->ug == ug) + { + ContextList = eina_list_remove_list(ContextList, l); + break; + } + } + + if(Context->callback_handle) + { + ivug_callback_unregister(Context->callback_handle); + } + +#ifdef USE_NEW_DB_API + PERF_CHECK_BEGIN(LVL2, "ivug_db_destroy"); + ivug_db_destroy(); + PERF_CHECK_END(LVL2, "ivug_db_destroy"); +#endif + + PERF_CHECK_BEGIN(LVL2, "elm_theme_free"); + if(Context->th) + { + int i = 0; + for ( i = 0; edj[i] != NULL; i++) + { + elm_theme_extension_del(Context->th, edj[i]); + } + elm_theme_free(Context->th); + } + PERF_CHECK_END(LVL2, "elm_theme_free"); + + MSG_IVUG_HIGH("Remove from list. Context=0x%08x, ug=0x%08x", Context, Context->ug); + + free(Context); + + return true; +} + + +void ivug_context_destroy_me(const char *file, int line) +{ +#if 0 + int x = 0; + int y = 0; + int w = 0; + int h = 0; + + MSG_MAIN_WARN("Apply event blocker"); + pMainView->event_blocker = evas_object_rectangle_add(evas_object_evas_get(pMainView->layout)); + evas_object_geometry_get(pMainView->layout, &x, &y, &w, &h); + evas_object_move(pMainView->event_blocker, x, y); + evas_object_resize(pMainView->event_blocker, w, h); + evas_object_color_set(pMainView->event_blocker, 0, 0, 0, 0); + evas_object_show(pMainView->event_blocker); + + if(/* It is launched by app service */) + { + MSG_MAIN_HIGH("Hide UG"); + elm_win_lower(ug_get_window()); + return; + } +#endif + AppData *ugContext; + ugContext = eina_list_data_get(ContextList); + + //IV_ASSERT(ugContext != NULL); + if (NULL != ugContext) { + + MSG_IMAGEVIEW_HIGH("Get ug handle = 0x%08x", ugContext->ug); + ug_destroy_me(ugContext->ug); + } else { + MSG_IMAGEVIEW_HIGH("ugContext is NULL."); + } + +} + + diff --git a/main/src/control/ivug-context.h b/main/src/control/ivug-context.h new file mode 100755 index 0000000..69e9270 --- /dev/null +++ b/main/src/control/ivug-context.h @@ -0,0 +1,71 @@ +/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.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 __IVUG_CONTEXT_H__ +#define __IVUG_CONTEXT_H__ + +#include "ivug-common.h" +#include "ivug-callback.h" +#include <ui-gadget.h> + +/* + Managing context(instance) +*/ +#ifdef __cplusplus +extern "C" { +#endif + +bool +ivug_context_deinit(ui_gadget_h ug); + +bool +ivug_context_init(ui_gadget_h ug); + +void +ivug_context_destroy_me(const char *file, int line); + +#define DESTROY_ME() \ + do { \ + ivug_context_destroy_me(__FILE__, __LINE__); \ + } while(0) + +void +gSetRotationDegree(int degree); + +Elm_Theme* +gGetSystemTheme(void); + +int +gGetRotationDegree(void); + +ui_gadget_h +gGetUGHandle(void); + +Evas_Object * +gGetCurrentWindow(void); + +callback_handle_t * +gGetCallbackHandle(void); + +int gGetScreenWidth(); +int gGetScreenHeight(); + +#ifdef __cplusplus +} +#endif + +#endif //__IVUG_CONTEXT_H__
\ No newline at end of file diff --git a/main/src/control/ivug-crop-ug.cpp b/main/src/control/ivug-crop-ug.cpp new file mode 100755 index 0000000..13bcb40 --- /dev/null +++ b/main/src/control/ivug-crop-ug.cpp @@ -0,0 +1,142 @@ +/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.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 <ui-gadget.h> +#include <ui-gadget-module.h> // ug_destroy_me, ug_send_result + +#include "ivug-crop-view.h" +#include "ivug-crop-ug.h" + +#include "ivug-debug.h" +#include "ivug-string.h" +#include "ivug-context.h" + +#undef LOG_LVL +#define LOG_LVL DBG_MSG_LVL_MED + +#undef LOG_CAT +#define LOG_CAT "IV-CROP-UG" + +static void +_send_result(ui_gadget_h ug, const char *key1, const char *val1, const char *key2, const char *val2) +{ + ivug_ret_if(!ug); + + service_h service; + service_create(&service); + + if(key1 && val1) + { + MSG_HIGH("Bundle 1 : [%s = %s]", key1, val1); + service_add_extra_data(service, key1, val1); + } + if(key2 && val2) + { + MSG_HIGH("Bundle 2 : [%s = %s]", key2, val2); + service_add_extra_data(service, key2, val2); + } + ug_send_result(gGetUGHandle(), service); + + service_destroy(service); +} + +static void _ivug_crop_view_ok_clicked_cb(void *data, Evas_Object *obj, void *event_info) +{ + char *path = (char *)event_info; + + evas_object_smart_callback_del(obj, "ok,clicked", _ivug_crop_view_ok_clicked_cb); + + _send_result(gGetUGHandle(), "crop_image_path", path, NULL, NULL); + + MSG_HIGH("Start destroy ug"); + ug_destroy_me(gGetUGHandle()); +} + +static void _ivug_crop_view_cancel_clicked_cb(void *data, Evas_Object *obj, void *event_info) +{ + //ivug_crop_ug_destroy((IvugCropUG *)data); + + evas_object_smart_callback_del(obj, "cancel,clicked", _ivug_crop_view_cancel_clicked_cb); + + _send_result(gGetUGHandle(), "crop_image_path", NULL, NULL, NULL); + + MSG_HIGH("Start destroy ug"); + ug_destroy_me(gGetUGHandle()); +} + +static void _ivug_crop_view_destroyed_cb(void *data, Evas_Object *obj, void *event_info) +{
+ IvugCropUG *crop_ug = (IvugCropUG *)data; + + crop_ug->crop_view = NULL; +} + +IvugCropUG * ivug_crop_ug_create(Evas_Object *parent, int w, int h, bool bRatioFix, const char *filepath) +{ + IvugCropUG *crop_ug = (IvugCropUG *)calloc(1, sizeof(IvugCropUG)); + + IvugCropView *crop_view = NULL; + Evas_Object *layout = NULL; + + crop_view = ivug_crop_view_create(parent); + if(crop_view == NULL) + { + MSG_ERROR("ivug_crop_view_create error"); + return NULL; + } + + ivug_crop_view_box_size_set(crop_view, w, h); + ivug_crop_view_file_set(crop_view, filepath); + ivug_crop_view_box_ratio_fix(crop_view, bRatioFix); + + layout = ivug_crop_view_get_object(crop_view); + + evas_object_smart_callback_add(layout, "ok,clicked", _ivug_crop_view_ok_clicked_cb, crop_ug); + evas_object_smart_callback_add(layout, "cancel,clicked", _ivug_crop_view_cancel_clicked_cb, crop_ug); + evas_object_smart_callback_add(layout, "destroyed", _ivug_crop_view_destroyed_cb, crop_ug); + + crop_ug->crop_view = crop_view; + crop_ug->layout = layout; + crop_ug->parent = parent; + + return crop_ug; +} + +Evas_Object * ivug_crop_ug_get_layout(IvugCropUG * crop_ug) +{ + IV_ASSERT(crop_ug != NULL); + + return crop_ug->layout; +} + +bool ivug_crop_ug_destroy(IvugCropUG * crop_ug) +{ + IV_ASSERT(crop_ug != NULL); + + if(crop_ug->crop_view) + { + ivug_crop_view_destroy(crop_ug->crop_view); + crop_ug->crop_view = NULL; + } + crop_ug->layout = NULL; + + free(crop_ug); + + return true; +} + + diff --git a/main/src/control/ivug-crop-ug.h b/main/src/control/ivug-crop-ug.h new file mode 100755 index 0000000..d1921a1 --- /dev/null +++ b/main/src/control/ivug-crop-ug.h @@ -0,0 +1,44 @@ +/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.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 __IVUG_CROP_UG_H__ +#define __IVUG_CROP_UG_H__ + +#include "ivug-crop-view.h" + +typedef struct { + IvugCropView *crop_view; + Evas_Object *layout; + Evas_Object *parent; +} IvugCropUG; + +#ifdef __cplusplus +extern "C" { +#endif + +IvugCropUG * ivug_crop_ug_create(Evas_Object *parent, int w, int h, bool bRatioFix, const char *filepath); + +Evas_Object * ivug_crop_ug_get_layout(IvugCropUG * crop_ug); + +bool ivug_crop_ug_destroy(IvugCropUG * crop_ug); + + +#ifdef __cplusplus +} +#endif + +#endif // __IVUG_CROP_UG_H__ + diff --git a/main/src/control/ivug-detail-info.c b/main/src/control/ivug-detail-info.c new file mode 100755 index 0000000..d6f7f9f --- /dev/null +++ b/main/src/control/ivug-detail-info.c @@ -0,0 +1,703 @@ +/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.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 "ivug-detail-info.h" + +#include <vconf.h> +#include <vconf-keys.h> + +#include <drm_client.h> + +#include <runtime_info.h> + +#include <glib.h> + +#include <unicode/udat.h> +#include <unicode/ustring.h> +#include <unicode/uloc.h> +#include <unicode/ucal.h> +#include <unicode/udatpg.h> +#include <unicode/utmscale.h> + +#include "ivug-details-view.h" +#include <libexif/exif-data.h> + +#include "ivug-drm.h" +#include "ivug-file-info.h" + +#define NOMAL_BUF 128 + +#define DETAILS_DIR_PATH_LEN_MAX 4096 + +enum IVUG_SIZE_TYPE +{ + SIZE_BYTE = 0, + SIZE_KB, + SIZE_MB, + SIZE_GB +}; + +/* + Shuld free returned value after use +*/ +static char* +_get_icu_time_string(const char *locale, const char *customSkeleton, const char *timezone, UDate date) +{ +#define UG_ICU_ARR_LENGTH 256 + + IV_ASSERT(customSkeleton != NULL); + IV_ASSERT(timezone != NULL); + + /* + Copy a byte string encoded in the default codepage to a ustring. + Copies at most n characters. The result will be null terminated if the length of src is less than n. Performs a host byte to UChar conversion + */ + UChar ucustomSkeleton[UG_ICU_ARR_LENGTH] = {0,}; + + if(u_uastrncpy(ucustomSkeleton, customSkeleton, UG_ICU_ARR_LENGTH) == NULL) + { + MSG_UTIL_ERROR("u_uastrncpy() error."); + return NULL; + } + + UChar utimezone[UG_ICU_ARR_LENGTH] = {0,}; + + if ( u_uastrncpy(utimezone, timezone, UG_ICU_ARR_LENGTH) == NULL ) + { + MSG_UTIL_ERROR("u_uastrncpy() error."); + return NULL; + } + + UErrorCode status = U_ZERO_ERROR; + UDateTimePatternGenerator *generator; + UDateFormat *formatter; + + UChar bestPattern[UG_ICU_ARR_LENGTH] = {0,}; + UChar formatted[UG_ICU_ARR_LENGTH] = {0,}; + char formattedString[UG_ICU_ARR_LENGTH] = {0,}; + int32_t bestPatternLength, formattedLength; + + ucal_setDefaultTimeZone(utimezone , &status); + + if (U_FAILURE(status)) + { + MSG_UTIL_ERROR("ucal_setDefaultTimeZone() is failed"); + return NULL; + } + + uloc_setDefault(getenv("LC_TIME"), &status); + + if (U_FAILURE(status)) + { + MSG_UTIL_ERROR("ucal_setDefaultTimeZone() is failed"); + return NULL; + } + + generator = udatpg_open(locale, &status); + if(generator == NULL) + { + return NULL; + } + + bestPatternLength = udatpg_getBestPattern(generator, ucustomSkeleton, u_strlen(ucustomSkeleton), bestPattern, UG_ICU_ARR_LENGTH, &status); + if(bestPatternLength <= 0) + { + return NULL; + } + + formatter = udat_open(UDAT_IGNORE, UDAT_IGNORE, locale, NULL, -1, bestPattern, -1, &status); + if(formatter == 0) + { + return NULL; + } + + formattedLength = udat_format(formatter, date, formatted, UG_ICU_ARR_LENGTH, NULL, &status); + if(formattedLength <= 0) + { + return NULL; + } + + u_austrcpy(formattedString, formatted); + udatpg_close(generator); + udat_close(formatter); + + if(strlen(formattedString) == 0) + { + return NULL; + } + + return strdup(formattedString); +} + + +/* + Should free returned value after use +*/ +static char * +_get_drm_availabile_string(drm_permission_type_e permissionType) +{ + switch(permissionType) + { + case DRM_PERMISSION_TYPE_ANY: + return strdup(IDS_ANY); + break; + + case DRM_PERMISSION_TYPE_PLAY: + return strdup(IDS_PLAY); + break; + + case DRM_PERMISSION_TYPE_COLLABORATIVE_PLAY: + return strdup(IDS_COLLABORATIVE_PLAY); + break; + + case DRM_PERMISSION_TYPE_DISPLAY: + return strdup(IDS_DISPLAY); + break; + + case DRM_PERMISSION_TYPE_EXECUTE: + return strdup(IDS_EXECUTE); + break; + + case DRM_PERMISSION_TYPE_PRINT: + return strdup(IDS_PRINT); + break; + + case DRM_PERMISSION_TYPE_EXPORT_COPY: + return strdup(IDS_COPY); + break; + + case DRM_PERMISSION_TYPE_EXPORT_MOVE: + return strdup(IDS_MOVE); + break; + + default: + return strdup(IDS_N_A); + break; + + } +} + +static char* +_get_icu_date(time_t mtime) +{ +#define UG_DATE_FORMAT_12 "yMMMdhms" +#define UG_DATE_FORMAT_24 "yMMMdHms" + + char* skeleton = NULL; + + bool hours_24 = false; + int ret = -1; + + ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_24HOUR_CLOCK_FORMAT_ENABLED, &hours_24); + if(ret != RUNTIME_INFO_ERROR_NONE) + { + MSG_DETAIL_ERROR("Cannot get 24 hours format"); + return NULL; + } + + if(hours_24 == true) + { + skeleton = UG_DATE_FORMAT_24; + } + else + { + skeleton = UG_DATE_FORMAT_12; + } + + char *locale = vconf_get_str(VCONFKEY_REGIONFORMAT); /* eg. en_US.UTF-8*/ + if(locale == NULL) + { + MSG_DETAIL_ERROR("Cannot get region format."); + locale = "en_US.UTF-8"; // Default value. + } + + char *timezone = NULL; + + timezone = vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_ID); // eg Asia/Seoul + if(timezone == NULL) + { +// TODO : How to get default time zone???? + MSG_DETAIL_ERROR("Cannot get time zone"); + return NULL; + } + + MSG_DETAIL_HIGH("Locale:%s TimeZone:%s TimeFormat:%s", locale, skeleton, timezone); + + char* datestr = NULL; + + datestr = _get_icu_time_string(locale, skeleton, timezone, (UDate)mtime * 1000); + + if(datestr == NULL) + { + MSG_DETAIL_ERROR("Cannot get time string"); + return NULL; + } + + MSG_DETAIL_HIGH("ICU Date : %s", datestr); + return datestr; + +} + +static char * +_get_filesize_string(size_t size) +{ +#define FILE_SIZE_LEN_MAX 64 + + MSG_DETAIL_HIGH("Entered size = %d", size); + + char *tmp = (char *)calloc(1, sizeof(char)*(FILE_SIZE_LEN_MAX+1)); + if (tmp == NULL) + { + return NULL; + } + + if(size > (1<<30)) // GB + { + snprintf(tmp,FILE_SIZE_LEN_MAX,"%.1f GB", (double)size/(1<<30)); + } + else if(size > (1<<20)) // MB + { + snprintf(tmp,FILE_SIZE_LEN_MAX,"%.1f MB", (double)size/(1<<20)); + } + else if(size > (1<<10)) // KB + { + snprintf(tmp,FILE_SIZE_LEN_MAX,"%zu KB", size/(1<<10)); + } + else // Byte + { + snprintf(tmp,FILE_SIZE_LEN_MAX,"%zu B", size); + } + + MSG_DETAIL_HIGH("Result Size = %s", tmp); + return tmp; +} + +void +ivug_details_info_set_file_information(ivug_file_info_t * const pFileInfo, const char *path) +{ + ivug_ret_if( NULL == pFileInfo ); + ivug_ret_if( NULL == path ); + +/*** get file path*/ + pFileInfo->filepath = strdup(path); + + struct stat statbuf; + + if(stat(path,&statbuf) == -1) + { + MSG_DETAIL_ERROR("Cannot get stat()"); + return ; + } + + pFileInfo->size = statbuf.st_size; + pFileInfo->date = statbuf.st_mtime; + + pFileInfo->create_date = _get_icu_date(pFileInfo->date); + + if ( pFileInfo->create_date == NULL ) + { + pFileInfo->create_date = strdup(IDS_N_A); + } + + pFileInfo->file_ext = ivug_fileinfo_get_file_extension(path); + + if ( pFileInfo->file_ext == NULL ) + { + pFileInfo->file_ext = strdup(IDS_UNKNOWN); + } + + pFileInfo->filesize = _get_filesize_string(pFileInfo->size); + + MSG_DETAIL_HIGH("Basic Info : ext=%s size=%s", pFileInfo->file_ext, pFileInfo->filesize); + + return ; + +} + + +void +ivug_details_info_set_gps_info(ivug_file_info_t * const pFileInfo, const char *path) +{ +#define UG_EXIF_ARR_LENGTH 255 + + ivug_retm_if(!pFileInfo, "data is NULL"); + ivug_retm_if(!path, "path is NULL"); + + pFileInfo->longitude = calloc(1, sizeof(char)*UG_EXIF_ARR_LENGTH); + if(pFileInfo->longitude == NULL) + { + return; + } + + pFileInfo->latitude = calloc(1, sizeof(char)*UG_EXIF_ARR_LENGTH); + if(pFileInfo->latitude == NULL) + { + return; + } + + + double longtitude = 0.0; + double latitude = 0.0; + + bool bret = false; + + if(pFileInfo->file_type == IVUG_DETAIL_IMAGE_TYPE) // this will be removed!!!! + { + bret = ivug_fileinfo_get_image_gps_info(path, &latitude, &longtitude); + } + else if(pFileInfo->file_type == IVUG_DETAIL_VIDEO_TYPE) + { + bret = ivug_fileinfo_get_video_gps_info(path, &latitude, &longtitude); + } + + if ( bret == false) + { + latitude = 0; + longtitude = 0; + } + + if(latitude != 0.0) + { + snprintf(pFileInfo->latitude, UG_EXIF_ARR_LENGTH, "%.5f", latitude); + } + else + { + snprintf(pFileInfo->latitude, UG_EXIF_ARR_LENGTH, "%s", IDS_UNKNOWN); + } + if(longtitude != 0.0) + { + snprintf(pFileInfo->longitude, UG_EXIF_ARR_LENGTH, "%.5f", longtitude); + } + else + { + snprintf(pFileInfo->longitude, UG_EXIF_ARR_LENGTH, "%s", IDS_UNKNOWN); + } +} + +void +ivug_details_info_set_resolution(ivug_file_info_t * const pFileInfo, const char *path, int stype) +{ + ivug_retm_if(!pFileInfo, "data is NULL"); + ivug_retm_if(!path, "path is NULL"); + + MSG_DETAIL_HIGH("slide type is %d", stype); + + pFileInfo->resolution = (char *)malloc(sizeof(char)*NOMAL_BUF+1); + if(pFileInfo->resolution == NULL) + { + return ; + } + memset(pFileInfo->resolution,0,(sizeof(char)* NOMAL_BUF + 1)); + + + int width, height; + + switch(stype) + { + /*Image type && !drm*/ + case SLIDE_TYPE_IMAGE: + pFileInfo->file_type = IVUG_DETAIL_IMAGE_TYPE; + + if ( ivug_fileinfo_get_image_resolution(path, &width, &height) == false) + { + snprintf(pFileInfo->resolution, NOMAL_BUF, "%s", IDS_N_A); + } + else + { + snprintf(pFileInfo->resolution, NOMAL_BUF,"%dX%d", width, height); + } + + break; + + /* Video type */ + case SLIDE_TYPE_VIDEO: + pFileInfo->file_type = IVUG_DETAIL_VIDEO_TYPE; + + if ( ivug_fileinfo_get_video_resolution(path, &width, &height) == false) + { + snprintf(pFileInfo->resolution, NOMAL_BUF, "%s", IDS_N_A); + } + else + { + snprintf(pFileInfo->resolution, NOMAL_BUF,"%dX%d", width, height); + } + + + break; + + case SLIDE_TYPE_STREAMING: + pFileInfo->file_type = IVUG_DETAIL_VIDEO_TYPE; + break; + + default: + break; + + } + +} + +void +ivug_details_info_set_location(ivug_file_info_t * const pFileInfo, const char *path) +{ + ivug_retm_if(!pFileInfo, "data is NULL"); + ivug_retm_if(!path, "path is NULL"); + + pFileInfo->file_location = strdup(path); +} + +void +ivug_details_info_set_filename(ivug_file_info_t * const pFileInfo, const char *path) +{ + ivug_retm_if(!pFileInfo, "data is NULL"); + ivug_retm_if(!path, "path is NULL"); + + /** get file name */ + pFileInfo->filename = ecore_file_strip_ext(ecore_file_file_get(path)); +} + +void _add_string(char *org, char *add_string) +{ + char *string = strdup(add_string); + if(org == NULL) + { + org = string; + } + else + { + org = g_strconcat(org, "/", string, NULL); + free(string); + } +} + +void +ivug_details_info_set_drm_info(ivug_file_info_t * const pFileInfo, const char *path) +{ +#define VALIDITY_SIZE 80 + +#define MOUNTH_COUNT 12 //used for drm file info, +#define DAY_COUNT 30 +#define HOUR_COUNT 24 +#define SECOND_COUNT 3600.0 + + ivug_retm_if(!pFileInfo, "data is NULL"); + ivug_retm_if(!path, "path is NULL"); + + pFileInfo->vendor = NULL; + pFileInfo->forwarding = NULL; + pFileInfo->available_uses = NULL; + pFileInfo->type = NULL; + + bool valid_ro = false; + + valid_ro = ivug_drm_has_valid_ro(path); + + if(false == valid_ro) + { + MSG_DETAIL_WARN("%s is not valid right object", path); + return ; + } + +// Get Vendor + pFileInfo->vendor = ivug_drm_get_drm_vendor_info(path); + + if ( pFileInfo->vendor == NULL ) + { + // Set default value. + pFileInfo->vendor = strdup(IDS_UNKNOWN); + } + +// Get forwarding + if ( ivug_drm_get_forwarding_info(path) == true ) + { + pFileInfo->forwarding = strdup(IDS_POSSIBLE); + } + else + { + pFileInfo->forwarding = strdup(IDS_IMPOSSIBLE); + } + +// Get Validity/Type/Available + + drm_constraint_info_s constraint_info; + int ret = -1; + int i = -1; + char *string = NULL; + char validity[VALIDITY_SIZE] = ""; + + for(i=DRM_PERMISSION_TYPE_NONE; i<=DRM_PERMISSION_TYPE_EXPORT_MOVE; i++) + { + memset(&constraint_info, 0x0, sizeof(drm_constraint_info_s)); + + ret = drm_get_constraint_info(path, i, &constraint_info); + if(ret != DRM_RETURN_SUCCESS) + { + MSG_IVUG_ERROR("drm_get_constraint_info Failed!!, perm_type=%d ret=0x%x", i, ret); + continue; + } + + string = _get_drm_availabile_string(i); + _add_string(pFileInfo->available_uses, string); + free(string); + + if(constraint_info.const_type.is_unlimited) + { + MSG_IVUG_HIGH("Unlimited:for permission=%d", i); + + _add_string(pFileInfo->type, IDS_UNLIMITED); + _add_string(pFileInfo->validity, IDS_UNLIMITED); + } + + if(constraint_info.const_type.is_accumulated){ + MSG_IVUG_HIGH("Accumulated Constraint is present"); + MSG_IVUG_HIGH("accumulated_original_seconds=%d", + constraint_info.accumulated_original_seconds); + MSG_IVUG_HIGH("accumulated_remaining_seconds=%d", + constraint_info.accumulated_remaining_seconds); + + _add_string(pFileInfo->type, IDS_ACCUMULATED_TIME); + snprintf(validity, sizeof(validity),"Total %.1f hours", + constraint_info.accumulated_remaining_seconds/SECOND_COUNT); + _add_string(pFileInfo->validity, validity); + } + + if(constraint_info.const_type.is_count){ + MSG_IVUG_HIGH("Count Constraint is present"); + MSG_IVUG_HIGH("original_count=%d", + constraint_info.original_count); + MSG_IVUG_HIGH("remaining_count=%d", + constraint_info.remaining_count); + + _add_string(pFileInfo->type, IDS_COUNT); + snprintf(validity, sizeof(validity),"%d left", constraint_info.remaining_count); + _add_string(pFileInfo->validity, validity); + } + + if(constraint_info.const_type.is_datetime){ + MSG_IVUG_HIGH("DATETIME Constraint is present"); + MSG_IVUG_HIGH("start_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.start_time.tm_year, + constraint_info.start_time.tm_mon, + constraint_info.start_time.tm_mday, + constraint_info.start_time.tm_hour, + constraint_info.start_time.tm_min, + constraint_info.start_time.tm_sec); + + MSG_IVUG_HIGH("end_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.end_time.tm_year, + constraint_info.end_time.tm_mon, + constraint_info.end_time.tm_mday, + constraint_info.end_time.tm_hour, + constraint_info.end_time.tm_min, + constraint_info.end_time.tm_sec); + + _add_string(pFileInfo->type, IDS_TIME); + snprintf(validity, sizeof(validity),"%d.%d.%d %d:%d ~ %d.%d.%d %d:%d:%d", + constraint_info.start_time.tm_mday, + constraint_info.start_time.tm_mon, + constraint_info.start_time.tm_year, + constraint_info.start_time.tm_hour, + constraint_info.start_time.tm_sec, + constraint_info.end_time.tm_mday, + constraint_info.end_time.tm_mon, + constraint_info.end_time.tm_year, + constraint_info.end_time.tm_hour, + constraint_info.end_time.tm_min, + constraint_info.end_time.tm_sec + ); + _add_string(pFileInfo->validity, validity); + } + + if(constraint_info.const_type.is_individual){ + MSG_IVUG_HIGH("INDIVIDUAL Constraint is present"); + MSG_IVUG_HIGH("individual_identity_type=%d " + "individual_id=%s", + constraint_info.individual_identity_type, + constraint_info.individual_id); + + _add_string(pFileInfo->type, IDS_INDIVIDUAL); + _add_string(pFileInfo->validity, IDS_INDIVIDUAL); + } + + if(constraint_info.const_type.is_interval){ + MSG_IVUG_HIGH("INTERVAL Constraint is present"); + MSG_IVUG_HIGH("interval_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.interval_time.tm_year, + constraint_info.interval_time.tm_mon, + constraint_info.interval_time.tm_mday, + constraint_info.interval_time.tm_hour, + constraint_info.interval_time.tm_min, + constraint_info.interval_time.tm_sec); + + _add_string(pFileInfo->type, IDS_INTERVAL); + if(constraint_info.interval_time.tm_year == 0 + && constraint_info.interval_time.tm_mon == 0 + && constraint_info.interval_time.tm_mday == 0 + && constraint_info.interval_time.tm_hour == 0) + { + snprintf(validity, sizeof(validity),"Total %d miniutes", constraint_info.interval_time.tm_min); + } + else + { + snprintf(validity, sizeof(validity),"Total %d hours", + ((constraint_info.interval_time.tm_year*MOUNTH_COUNT + + constraint_info.interval_time.tm_mon)*DAY_COUNT + + constraint_info.interval_time.tm_mday)*HOUR_COUNT + + constraint_info.interval_time.tm_hour + ); + } + _add_string(pFileInfo->validity, validity); + } + + if(constraint_info.const_type.is_system){ + MSG_IVUG_HIGH("SYSTEM Constraint is present"); + MSG_IVUG_HIGH("system_identity_type=%d " + "system_id=%s", + constraint_info.system_identity_type, + constraint_info.system_id); + + _add_string(pFileInfo->type, IDS_SYSTEM); + _add_string(pFileInfo->validity, IDS_SYSTEM); + } + + if(constraint_info.const_type.is_timedcount){ + MSG_IVUG_HIGH("TIMED-COUNT Constraint is present"); + MSG_IVUG_HIGH("timed_original_count=%d", + constraint_info.timed_original_count); + + MSG_IVUG_HIGH("timed_remaining_count=%d", + constraint_info.timed_remaining_count); + + MSG_IVUG_HIGH("timed_count_timer=%d", + constraint_info.timed_count_timer); + + _add_string(pFileInfo->type, IDS_TIMED_COUNT); + snprintf(validity, sizeof(validity),"%d (%d sec)", + constraint_info.timed_remaining_count, + constraint_info.timed_count_timer + ); + _add_string(pFileInfo->validity, validity); + } + + MSG_IVUG_WARN("Undefined constraints"); + } + + return; +} + + diff --git a/main/src/control/ivug-detail-info.h b/main/src/control/ivug-detail-info.h new file mode 100755 index 0000000..b98f14b --- /dev/null +++ b/main/src/control/ivug-detail-info.h @@ -0,0 +1,85 @@ +/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.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 __IVUG_DETAIL_COMMON_H__ +#define __IVUG_DETAIL_COMMON_H__ + +#include <unicode/udat.h> + +#include "ivug-common.h" +#include "ivug-drm.h" + +typedef enum { + IVUG_DETAIL_ERROR_TYPE = -1, + IVUG_DETAIL_IMAGE_TYPE, + IVUG_DETAIL_VIDEO_TYPE +} ivug_detail_file_t; + +typedef struct { +/** Common info*/ + time_t date; // Seconds since 1970-1-1 + size_t size; + + ivug_detail_file_t file_type; + + char *filesize; + char *filepath; + char *filename; + char *file_ext; + char *file_location; + char *contains; + char *create_date; + +/**resolution */ + char *resolution; + +/**Gps info */ + char *latitude; + char *longitude; + +/** Drm info */ + char *vendor; + char *forwarding; + char *available_uses; + char *type; + char *validity; +}ivug_file_info_t; + +#ifdef __cplusplus +extern "C" { +#endif + +// TODO : Remove dependacy ivug-detail-view and ivug-detail-info. + +void ivug_details_info_set_file_information(ivug_file_info_t * const pFileInfo, const char *path); + +void ivug_details_info_set_gps_info(ivug_file_info_t * const pFileInfo, const char *path); + +void ivug_details_info_set_resolution(ivug_file_info_t * const pFileInfo, const char *path, int stype); + +void ivug_details_info_set_location(ivug_file_info_t * const pFileInfo, const char *path); + +void ivug_details_info_set_filename(ivug_file_info_t * const pFileInfo, const char *path); + +void ivug_details_info_set_drm_info(ivug_file_info_t * const pFileInfo,const char *path); + +#ifdef __cplusplus +} +#endif + + +#endif // __IVUG_DETAIL_COMMON_H__ + diff --git a/main/src/control/ivug-filter.c b/main/src/control/ivug-filter.c new file mode 100755 index 0000000..56e08f7 --- /dev/null +++ b/main/src/control/ivug-filter.c @@ -0,0 +1,161 @@ +/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.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 "ivug-datatypes.h" +#include "ivug-filter.h" + +#include <Eina.h> + +#include "ivug-debug.h" +#include "ivug-uuid.h" +#include "ivug-util.h" +#include "ivug-context.h" + +Filter_struct *ivug_data_filter_create(const ivug_parameter *param) +{ + IV_ASSERT(param != NULL); + + Filter_struct *filter_str = calloc(1, sizeof(Filter_struct)); + IV_ASSERT(filter_str != NULL); + + filter_str->type = FILTER_DB; + + filter_str->view_by = param->view_by; + filter_str->media_type = param->media_type; + filter_str->sort_type = param->sort_type; + filter_str->index = param->start_index; + + DB_Filter *filter = calloc(1, sizeof(DB_Filter)); + + IV_ASSERT(filter != NULL); + + MSG_SDATA_HIGH("param->view_by is %d", param->view_by); + switch(param->view_by) + { + case IVUG_VIEW_BY_PLACES: + filter->place.max_longitude = param->max_longitude; + filter->place.min_longitude = param->min_longitude; + filter->place.max_latitude = param->max_latitude; + filter->place.min_latitude = param->min_latitude; + break; + + case IVUG_VIEW_BY_FILE: + filter->file_path = strdup(param->filepath); + break; + case IVUG_VIEW_BY_ALL: + filter->album_id = uuid_assign(param->album_id); + break; + case IVUG_VIEW_BY_FOLDER: + filter->album_id = uuid_assign(param->album_id); + break; + case IVUG_VIEW_BY_INVAILD: + default: + MSG_SDATA_WARN("Invalid ViewBy : %d", param->view_by); + break; + + } + + filter_str->db_filter = filter; + + return filter_str; + +} + +void ivug_data_filter_delete(Filter_struct *filter_str) +{ + IV_ASSERT(filter_str != NULL); + + MSG_SDATA_HIGH("Removing filter struct. Type=%d", filter_str->type); + + if(filter_str->type == FILTER_DB) + { + DB_Filter *filter = filter_str->db_filter; + switch(filter_str->view_by) + { + case IVUG_VIEW_BY_PLACES: + break; + case IVUG_VIEW_BY_FILE: + if ( filter->file_path ) + { + free(filter->file_path); + } + break; + case IVUG_VIEW_BY_ALL: + uuid_free(filter->album_id); + break; + + case IVUG_VIEW_BY_FOLDER: + uuid_free(filter->album_id); + break; + + case IVUG_VIEW_BY_INVAILD: + default: + MSG_SDATA_WARN("Invalid ViewBy : %d", filter_str->view_by); + break; + } + free(filter); + } + free(filter_str); +} + + +Filter_struct *ivug_data_filter_copy(const Filter_struct *filter_str) +{ + IV_ASSERT(filter_str != NULL); + Filter_struct *cFilter_str = malloc(sizeof(Filter_struct)); + IV_ASSERT(cFilter_str != NULL); + + memcpy(cFilter_str, filter_str, sizeof(Filter_struct)); + + if(filter_str->type == FILTER_DB) + { + DB_Filter *filter = filter_str->db_filter; + DB_Filter *cFilter = malloc(sizeof(DB_Filter)); + memcpy(cFilter, filter, sizeof(DB_Filter)); + + switch(filter_str->view_by) + { + case IVUG_VIEW_BY_PLACES: + break; + + case IVUG_VIEW_BY_FILE: + cFilter->file_path = strdup( filter->file_path ); + + if ( filter->file_path ) + { + free(filter->file_path); + } + break; + + case IVUG_VIEW_BY_ALL: + cFilter->album_id = uuid_assign( filter->album_id ); + break; + + case IVUG_VIEW_BY_FOLDER: + cFilter->album_id = uuid_assign( filter->album_id ); + break; + + case IVUG_VIEW_BY_INVAILD: + default: + MSG_SDATA_WARN("Invalid ViewBy : %d", filter_str->view_by); + break; + } + + cFilter_str->db_filter = cFilter; + } + return cFilter_str; +} + diff --git a/main/src/control/ivug-filter.h b/main/src/control/ivug-filter.h new file mode 100755 index 0000000..482740d --- /dev/null +++ b/main/src/control/ivug-filter.h @@ -0,0 +1,41 @@ +/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.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 __IVUG_FILTER_H__ +#define __IVUG_FILTER_H__ + +#include "ivug-parameter.h" +#include "ivug-medialist.h" +#include <Eina.h> + + +#ifdef __cplusplus +extern "C" { +#endif + +Filter_struct *ivug_data_filter_create(const ivug_parameter *param); + +Filter_struct *ivug_data_filter_copy(const Filter_struct *filter); + +void ivug_data_filter_delete(Filter_struct *filter); + +#ifdef __cplusplus +} +#endif + + +#endif // __IVUG_FILTER_H__ + diff --git a/main/src/control/ivug-popup.c b/main/src/control/ivug-popup.c new file mode 100755 index 0000000..78c9d5e --- /dev/null +++ b/main/src/control/ivug-popup.c @@ -0,0 +1,643 @@ +/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.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 "ivug-popup.h" +#include "ivug-vibration.h" + +#define NOTIFY_TIMEOUT 3.0 + +#define IVUG_POPUP_EDJ_NAME EDJ_PATH"/ivug-popup.edj" + +typedef struct _Ivug_Popup +{ + Evas_Object *parent; + Evas_Object *popup; + Evas_Object *layout; + + Evas_Object *obj; + + int selected_index; + + Popup_Response response; + + int haptic_handle; + + Evas_Smart_Cb callback; + void *data; + +}Ivug_Popup; + +typedef struct +{ + int index; + char *name; + Evas_Object *radio_main; + Ivug_Popup *p_iv_popup; +} ivug_radio_popup_item; + +static Ivug_Popup * ivug_popup_create() +{ + Ivug_Popup *iv_popup = calloc(1, sizeof(Ivug_Popup)); + + iv_popup->haptic_handle = INVALID_HAPTIC_HANDLE; + + return iv_popup; +} + +static void ivug_popup_delete(Ivug_Popup *iv_popup) +{ + if ( iv_popup->haptic_handle != INVALID_HAPTIC_HANDLE ) + { + ivug_vibration_stop(iv_popup->haptic_handle); + ivug_vibration_delete(iv_popup->haptic_handle); + + iv_popup->haptic_handle = INVALID_HAPTIC_HANDLE; + } + + if(iv_popup->popup) + { + evas_object_del(iv_popup->popup); + iv_popup->popup = NULL; + } + + if(iv_popup->layout) + { + evas_object_del(iv_popup->layout); + iv_popup->layout = NULL; + } + + free(iv_popup); +} + +static void _on_popup_response(void *data, Evas_Object *obj, void *event_info ) +{ + IV_ASSERT(data != NULL); + + Ivug_Popup *iv_popup = (Ivug_Popup *)data; + Popup_Response response = (Popup_Response)evas_object_data_get(obj, "response"); + MSG_IMAGEVIEW_HIGH("response callback=%d", response); + + if(iv_popup->callback) + { + iv_popup->callback(iv_popup->data, iv_popup->popup, (void *)response); + } + + ivug_popup_delete(iv_popup); +} + + +static void _on_ctxpopup_dismissed( void *data, Evas_Object *obj, void *event_info ) +{ +// Triggered when clicked outside ctxpopup + MSG_IMAGEVIEW_HIGH("Dismissed response"); + + Ivug_Popup *iv_popup = (Ivug_Popup *)data; + + ivug_popup_delete(iv_popup); +} + +Evas_Object* +ivug_deletepopup_show(Evas_Object* parent, const char* title, + const char* contents, Evas_Smart_Cb response, void* user_data) +{ + Evas_Object *popup; + Evas_Object *btn_delete; + Evas_Object *btn_cancel; + //create popup + + IV_ASSERT(response != NULL); + + Ivug_Popup *iv_popup = ivug_popup_create(); + + popup = elm_popup_add(parent); + evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_object_text_set(popup, contents); + elm_object_part_text_set(popup, "title,text", title); + + btn_delete = elm_button_add(popup); + elm_object_style_set(btn_delete, "popup_button/default"); + elm_object_text_set(btn_delete, IDS_DELETE); + elm_object_part_content_set(popup, "button1", btn_delete); + evas_object_data_set(btn_delete, "response", (void *)POPUP_RESPONSE_OK); + evas_object_smart_callback_add(btn_delete, "clicked", _on_popup_response, iv_popup); + + btn_cancel = elm_button_add(popup); + elm_object_style_set(btn_cancel, "popup_button/default"); + elm_object_text_set(btn_cancel, IDS_CANCEL); + elm_object_part_content_set(popup, "button2", btn_cancel); + evas_object_data_set(btn_cancel, "response", (void *)POPUP_RESPONSE_CANCEL); + evas_object_smart_callback_add(btn_cancel, "clicked", _on_popup_response, iv_popup); + + iv_popup->popup = popup; + iv_popup->callback = response; + iv_popup->data = user_data; + + evas_object_show(popup); + + return popup; +} + + +Evas_Object* +ivug_2btn_popup_show(Evas_Object* parent, const char* title, + const char* contents, Evas_Smart_Cb response, void* user_data) +{ + IV_ASSERT(response != NULL); + + Ivug_Popup *iv_popup = ivug_popup_create(); + + Evas_Object *popup; + Evas_Object *btn_yes; + Evas_Object *btn_no; + //create popup + + popup = elm_popup_add(parent); + evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_object_text_set(popup, contents); + if(title) + { + elm_object_part_text_set(popup, "title,text", title); + } + + btn_yes = elm_button_add(popup); + elm_object_style_set(btn_yes, "popup_button/default"); + elm_object_text_set(btn_yes, IDS_YES); + elm_object_part_content_set(popup, "button1", btn_yes); + evas_object_data_set(btn_yes, "response", (void *)POPUP_RESPONSE_OK); + evas_object_smart_callback_add(btn_yes, "clicked", _on_popup_response, iv_popup); + + btn_no = elm_button_add(popup); + elm_object_style_set(btn_no, "popup_button/default"); + elm_object_text_set(btn_no, IDS_NO); + elm_object_part_content_set(popup, "button2", btn_no); + evas_object_data_set(btn_no, "response", (void *)POPUP_RESPONSE_CANCEL); + evas_object_smart_callback_add(btn_no, "clicked", _on_popup_response, iv_popup); + + iv_popup->popup = popup; + iv_popup->callback = response; + iv_popup->data = user_data; + + evas_object_show(popup); + evas_object_layer_set(popup, EVAS_LAYER_MAX); + + return popup; +}
+
+Evas_Object*
+ivug_1btn_popup_show(Evas_Object* parent, const char* title,
+ const char* contents, Evas_Smart_Cb response, void* user_data)
+{
+ IV_ASSERT(response != NULL);
+
+ Ivug_Popup *iv_popup = ivug_popup_create();
+
+ Evas_Object *popup;
+ Evas_Object *btn_yes;
+ //create popup
+
+ popup = elm_popup_add(parent);
+ evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_object_text_set(popup, contents);
+ if(title)
+ {
+ elm_object_part_text_set(popup, "title,text", title);
+ }
+
+ btn_yes = elm_button_add(popup);
+ elm_object_style_set(btn_yes, "popup_button/default");
+ elm_object_text_set(btn_yes, IDS_OK);
+ elm_object_part_content_set(popup, "button1", btn_yes);
+ evas_object_data_set(btn_yes, "response", (void *)POPUP_RESPONSE_OK);
+ evas_object_smart_callback_add(btn_yes, "clicked", _on_popup_response, iv_popup);
+
+ iv_popup->popup = popup;
+ iv_popup->callback = response;
+ iv_popup->data = user_data;
+
+ evas_object_show(popup);
+ evas_object_layer_set(popup, EVAS_LAYER_MAX);
+
+ return popup;
+}
+
+static void _on_longpress_popup_selected(void *data, Evas_Object *obj, void *event_info) +{ + IV_ASSERT(data != NULL); + + Ivug_Popup *iv_popup = (Ivug_Popup *)data; + + const char *label = elm_object_item_text_get((Elm_Object_Item *)event_info); + if(label == NULL) + { + MSG_MAIN_ERROR("label is NULL"); + ivug_popup_delete(iv_popup); + return; + } + MSG_MAIN_HIGH("text(%s) is clicked", label); + + Longpress_Popup_Response response = LPPOPUP_RESPONSE_NONE; + if(strncmp(label, IDS_COPY, strlen(label)) == 0) + { + response = LPPOPUP_RESPONSE_COPY; + } + else + { + MSG_MAIN_WARN("Unknown Share type : %s", label); + } + MSG_MAIN_HIGH("response=%d", response); + + if(iv_popup->callback) + { + iv_popup->callback(iv_popup->data, iv_popup->popup, (void *)response); + } + + ivug_popup_delete(iv_popup); +} + +Evas_Object* +ivug_longpress_popup_show(Evas_Object *parent, int x, int y, Evas_Smart_Cb response, void *data) +{ + Ivug_Popup *iv_popup = ivug_popup_create(); + + Evas_Object* ctx_popup = NULL; + + ctx_popup = elm_ctxpopup_add(parent); + + elm_ctxpopup_item_append(ctx_popup, IDS_COPY, NULL, _on_longpress_popup_selected, iv_popup); + + evas_object_smart_callback_add(ctx_popup, "dismissed", _on_ctxpopup_dismissed, iv_popup); + + evas_object_move(ctx_popup, x, y); + + iv_popup->popup = ctx_popup; + iv_popup->callback = response; + iv_popup->data = data; + + evas_object_show(ctx_popup); + + return ctx_popup; +} + +void +_ivug_rename_enter_click_cb(void *data, Evas_Object *obj, void *event_info) +{ + Ivug_Popup *iv_popup = (Ivug_Popup *)data; + IV_ASSERT(iv_popup != NULL); + + Evas_Object *entry = iv_popup->obj; + + char *name = elm_entry_markup_to_utf8 ( elm_entry_entry_get(entry) ); + + MSG_IMAGEVIEW_HIGH("name = %s", name); + + if(name) + { + char *new_name = NULL; + new_name = ivug_strip_string(name); + if(new_name == NULL) + { + MSG_IMAGEVIEW_ERROR( "rename failed"); + free(name); + ecore_imf_context_input_panel_hide(elm_entry_imf_context_get(entry)); + return; + } + elm_object_text_set(entry, new_name); + if(iv_popup->callback) + { + iv_popup->callback(iv_popup->data, iv_popup->popup, (void *)POPUP_RESPONSE_OK); + } + ivug_popup_delete(iv_popup); + } + else + { + //ecore_imf_context_input_panel_hide(elm_entry_imf_context_get(entry)); + } +} + +void +_ivug_rename_entry_changed(void *data, Evas_Object *obj, void *event_info) +{ + Ivug_Popup *iv_popup = (Ivug_Popup *)data; + IV_ASSERT(iv_popup != NULL); + + Evas_Object *entry = iv_popup->obj; + Evas_Object *btn_ok = elm_object_part_content_get(iv_popup->popup, "button1"); + + char *content = elm_entry_markup_to_utf8 ( elm_entry_entry_get(entry) ); + + if (strlen(content) == 0) + { + MSG_IMAGEVIEW_HIGH("ISF1 : %s", content); + elm_object_disabled_set(btn_ok, EINA_TRUE); + } + else + { + MSG_IMAGEVIEW_HIGH("ISF : %s", content); + elm_object_disabled_set(btn_ok, EINA_FALSE); + } + free(content); +} + +void +_ivug_rename_maxlength_reached(void *data, Evas_Object *obj, void *event_info) +{ + Ivug_Popup *iv_popup = (Ivug_Popup *)data; + IV_ASSERT(iv_popup != NULL); + + if ( iv_popup->haptic_handle == INVALID_HAPTIC_HANDLE ) + { + iv_popup->haptic_handle = ivug_vibration_create(); + } + else + { + ivug_vibration_stop(iv_popup->haptic_handle); + } + + ivug_vibration_play(iv_popup->haptic_handle ,VIBRATION_DURATION); + +} + +Evas_Object *ivug_rename_popup_show(Evas_Object *parent, const char *filename, Evas_Smart_Cb response, void *data) +{ + Evas_Object *popup = NULL; + Evas_Object *entry = NULL; + Evas_Object *layout = NULL; + + Ivug_Popup *iv_popup = ivug_popup_create(); + + popup = elm_popup_add(parent); + if(!popup) + { + MSG_IMAGEVIEW_ERROR("popup is NULL"); + goto ENTRY_POPUP_FREE; + } + //evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + //elm_object_style_set(popup, "menustyle"); + elm_object_part_text_set(popup, "title,text", "Rename"); + + layout = elm_layout_add(popup); + if(!layout) + { + MSG_IMAGEVIEW_ERROR("layout is NULL"); + goto ENTRY_POPUP_FREE; + } + if(elm_layout_file_set(layout, IVUG_POPUP_EDJ_NAME, "popup_entryview") == EINA_FALSE) + { + MSG_IMAGEVIEW_ERROR("elm_layout_file_set error");; + goto ENTRY_POPUP_FREE; + } + //evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + entry = elm_entry_add(popup); + elm_entry_scrollable_set(entry, EINA_TRUE); + elm_entry_single_line_set(entry, EINA_TRUE); + elm_object_text_set(entry, filename); + elm_entry_cursor_end_set(entry); + elm_object_part_content_set(layout, "elm.swallow.content", entry); + elm_object_content_set(popup, layout); + + evas_object_smart_callback_add(entry, "activated", _ivug_rename_enter_click_cb, iv_popup); + evas_object_smart_callback_add(entry, "changed", _ivug_rename_entry_changed, iv_popup); + + static Elm_Entry_Filter_Limit_Size limit_filter_data; + limit_filter_data.max_char_count = 64; + limit_filter_data.max_byte_count = 0; + elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &limit_filter_data); + evas_object_smart_callback_add(entry, "maxlength,reached", _ivug_rename_maxlength_reached, (void *)iv_popup); + + evas_object_show(layout); + + Evas_Object *btn_ok = elm_button_add(popup); + elm_object_style_set(btn_ok, "popup_button/default"); + elm_object_text_set(btn_ok, IDS_OK); + elm_object_part_content_set(popup, "button1", btn_ok); + evas_object_data_set(btn_ok, "response", (void *)POPUP_RESPONSE_OK); + evas_object_smart_callback_add(btn_ok, "clicked", _ivug_rename_enter_click_cb, iv_popup); + + Evas_Object *btn_cancel = elm_button_add(popup); + elm_object_style_set(btn_cancel, "popup_button/default"); + elm_object_text_set(btn_cancel, IDS_CANCEL); + elm_object_part_content_set(popup, "button2", btn_cancel); + evas_object_data_set(btn_cancel, "response", (void *)POPUP_RESPONSE_CANCEL); + evas_object_smart_callback_add(btn_cancel, "clicked", _on_popup_response, iv_popup); + + iv_popup->popup = popup; + iv_popup->callback = response; + iv_popup->data = data; + iv_popup->obj = entry; + + evas_object_show(popup); + + return popup; + +ENTRY_POPUP_FREE: + if(popup) + { + evas_object_del(popup); + } + if(layout) + { + evas_object_del(layout); + } + if(entry) + { + evas_object_del(entry); + } + return NULL; +} + +static void _block_clicked_cb(void *data, Evas_Object *obj, void *event_info) +{ + IV_ASSERT(data != NULL); + + Ivug_Popup *iv_popup = (Ivug_Popup *)data; + Popup_Response response = (Popup_Response)evas_object_data_get(obj, "response"); + MSG_IMAGEVIEW_HIGH("response callback=%d", response); + + if(iv_popup->callback) + { + iv_popup->callback(iv_popup->data, iv_popup->popup, (void *)response); + } + + ivug_popup_delete(iv_popup); +} + +static char * +_gl_text_get(void *data, Evas_Object *obj, const char *part) +{ + ivug_radio_popup_item *popup_item = (ivug_radio_popup_item *)data; + //int index = popup_item->index; + + if (strcmp(part, "elm.text") == 0) + { + return strdup(popup_item->name); + } + return NULL; +} + +static Evas_Object * +_gl_content_get(void *data, Evas_Object *obj, const char *part) +{ + ivug_radio_popup_item *popup_item = (ivug_radio_popup_item *)data; + + Evas_Object *radio; + Evas_Object *radio_main = popup_item->radio_main; + int index = popup_item->index; + int selected_index = popup_item->p_iv_popup->selected_index; + + if (strcmp(part, "elm.icon") == 0 || strcmp(part, "elm.swallow.icon") == 0) + { + radio = elm_radio_add(obj); + elm_radio_state_value_set(radio, index); + elm_radio_group_add(radio, radio_main); + if (index == selected_index) + elm_radio_value_set(radio, selected_index); + evas_object_size_hint_weight_set(radio, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(radio, EVAS_HINT_FILL, EVAS_HINT_FILL); + + return radio; + } + + return NULL; +} + +static void +_gl_del(void *data, Evas_Object *obj) +{ + ivug_radio_popup_item *popup_item = (ivug_radio_popup_item *)data; + + if(popup_item->name) + { + free(popup_item->name); + popup_item->name = NULL; + } + + free(popup_item); + + return; +} + +static void +_gl_sel(void *data, Evas_Object *obj, void *event_info) +{ + IV_ASSERT(data != NULL); + + Ivug_Popup *iv_popup = (Ivug_Popup *)data; + + Elm_Object_Item *item = (Elm_Object_Item *) event_info; + ivug_radio_popup_item *popup_item = NULL; + + MSG_IMAGEVIEW_HIGH("_gl_sel"); + + if (item) + { + popup_item = (ivug_radio_popup_item *)elm_object_item_data_get(item); + iv_popup->selected_index = popup_item->index; + elm_genlist_item_update(item); + + if(iv_popup->callback) + { + iv_popup->callback(iv_popup->data, iv_popup->popup, (void *)iv_popup->selected_index); + } + + ivug_popup_delete(iv_popup); + } +} + +Evas_Object *ivug_radio_popoup_show(Evas_Object *parent, char *title, + int selected_index, Eina_List *name_list, Evas_Smart_Cb response, void *data) +{ +#define GET_POPUP_HEIGHT(icnt) (((113*icnt-1) > 408) ? (408) : (113*icnt-1)) +#define GET_POPUP_WIDTH(icnt) (614) + + Evas_Object *popup; + int index = 0; + Elm_Object_Item *item; + Evas_Object *genlist; + Evas_Object *btn_close; + Evas_Object *radio_main; + + static Elm_Genlist_Item_Class itc = {0,}; + + ivug_radio_popup_item *popup_item; + + Ivug_Popup *iv_popup = ivug_popup_create(); + + popup = elm_popup_add(parent); + elm_object_style_set(popup, "min_menustyle"); + elm_object_part_text_set(popup, "title,text", title); + evas_object_smart_callback_add(popup, "block,clicked", _block_clicked_cb, iv_popup); + evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + btn_close = elm_button_add(popup); + elm_object_style_set(btn_close, "popup_button/default"); + elm_object_text_set(btn_close, IDS_CLOSE); + elm_object_part_content_set(popup, "button1", btn_close); + evas_object_data_set(btn_close, "response", (void *)POPUP_RESPONSE_OK); + evas_object_smart_callback_add(btn_close, "clicked", _on_popup_response, iv_popup); + + itc.item_style = "1text.1icon.2"; + itc.func.text_get = _gl_text_get; + itc.func.content_get = _gl_content_get; + itc.func.state_get = NULL; + itc.func.del = _gl_del; + + genlist = elm_genlist_add(popup); + evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_propagate_events_set(genlist, EINA_FALSE); + + radio_main = elm_radio_add(genlist); + elm_radio_state_value_set(radio_main, -1); + elm_radio_value_set(radio_main, -1); + evas_object_propagate_events_set(radio_main, EINA_FALSE); + + Eina_List *l = NULL; + char *name = NULL; + + EINA_LIST_FOREACH(name_list, l, name) + { + popup_item = calloc(1, sizeof(ivug_radio_popup_item)); + popup_item->index = index++; + popup_item->name = strdup(name); + popup_item->radio_main = radio_main; + popup_item->p_iv_popup = iv_popup; + + item = elm_genlist_item_append(genlist, &itc, (void *)popup_item, NULL, + ELM_GENLIST_ITEM_NONE, _gl_sel, iv_popup); + } + + Evas_Object *box; + box = elm_box_add(popup); + evas_object_size_hint_min_set(box, GET_POPUP_WIDTH(index-1) * elm_config_scale_get(), GET_POPUP_HEIGHT(index-1) * elm_config_scale_get()); + evas_object_show(genlist); + elm_box_pack_end(box, genlist); + elm_object_content_set(popup, box); + //elm_object_content_set(popup, genlist); + + iv_popup->popup = popup; + iv_popup->callback = response; + iv_popup->data = data; + iv_popup->obj = radio_main; + iv_popup->selected_index = selected_index; + + evas_object_show(popup); + + return popup; +} + + diff --git a/main/src/control/ivug-popup.h b/main/src/control/ivug-popup.h new file mode 100755 index 0000000..dd1a1ba --- /dev/null +++ b/main/src/control/ivug-popup.h @@ -0,0 +1,82 @@ +/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.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 __IVUG_POPUP_H__ +#define __IVUG_POPUP_H__ + +#include "ivug-common.h" + +typedef enum _Popup_Response +{ + POPUP_RESPONSE_NONE = -1, + POPUP_RESPONSE_TIMEOUT = -2, + POPUP_RESPONSE_OK = -3, + POPUP_RESPONSE_CANCEL = -4, + POPUP_RESPONSE_CLOSE = -5 +}Popup_Response; + +typedef enum _Longpress_Popup_Response +{ + LPPOPUP_RESPONSE_NONE = 0, + LPPOPUP_RESPONSE_COPY, + LPPOPUP_RESPONSE_MANUALLY_DETECT, +}Longpress_Popup_Response; + +// Selected data + +#ifdef __cplusplus +extern "C" { +#endif
+
+Evas_Object* ivug_1btn_popup_show(Evas_Object* parent, const char* title,
+ const char* contents, Evas_Smart_Cb response, void* user_data);
+
+ +/* + Create & show popup with 2 button (Yes/No) +*/ +Evas_Object* ivug_2btn_popup_show(Evas_Object* parent, const char* title, + const char* contents, Evas_Smart_Cb response, void* user_data); + +/* + Create & show popup with no button. + TODO : Rename function +*/ +
+Evas_Object* +ivug_deletepopup_show(Evas_Object* parent, const char* title, + const char* contents, Evas_Smart_Cb response, void* user_data); + + +/* + Create show copy popup in coordinate (x,y) +*/ +Evas_Object* ivug_longpress_popup_show(Evas_Object *parent, int x, int y, Evas_Smart_Cb response, void *data); + +Evas_Object* ivug_deletepopup_show(Evas_Object* parent, const char* title, + const char* contents, Evas_Smart_Cb response, void* user_data); + +Evas_Object *ivug_rename_popup_show(Evas_Object *parent, const char *filename, Evas_Smart_Cb response, void *data); + +Evas_Object *ivug_radio_popoup_show(Evas_Object *parent, char *title, + int selected_index, Eina_List *name_list, Evas_Smart_Cb response, void *data); + +#ifdef __cplusplus +} +#endif + + +#endif //__IVUG_POPUP_H__ diff --git a/main/src/control/ivug-selectioninfo.c b/main/src/control/ivug-selectioninfo.c new file mode 100755 index 0000000..10aa0c8 --- /dev/null +++ b/main/src/control/ivug-selectioninfo.c @@ -0,0 +1,151 @@ +/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.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 "ivug-common.h" + +#include <Elementary.h> + +#include "ivug-selectioninfo.h" + +#define NOTIFY_TIMEOUT 3.0 + +static void +_ivug_selectioninfo_timeout_cb(void *data, Evas_Object *obj, void *event_info) +{ + ivug_ret_if(obj == NULL); + + evas_object_del(obj); + obj = NULL; +} + +static void _on_resize(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + Evas_Coord x,y,w,h; + evas_object_geometry_get(obj, &x, &y, &w, &h); + + MSG_IMAGEVIEW_HIGH("Selection resized geomtery XYWH(%d,%d,%d,%d) angle=%d", x, y, w, h, gGetRotationDegree()); + + Evas_Object* layout = elm_object_content_get(obj); + ivug_retm_if(layout == NULL, "Notify content is NULL"); + + //Get the selectioninfo text + const char* text = edje_object_part_text_get(_EDJ(layout), "elm.text"); + +#ifdef USE_CUSTOM_STYLE + elm_object_theme_set(layout, gGetSystemTheme()); + + int rot_angle = gGetRotationDegree(); + if ( (rot_angle == 0) || (rot_angle == 180) ) + { + elm_layout_theme_set(layout, "standard", "selectioninfo", "vertical/bottom_86"); + } + else + { + elm_layout_theme_set(layout, "standard", "selectioninfo", "horizontal/bottom_64"); + } +#endif + + if(text) + { + //Reset the text, because the text will be missed if no reset + edje_object_part_text_set(_EDJ(layout), "elm.text", text); + } + +} + + +Evas_Object* +ivug_selectioninfo_create(Evas_Object* parent, const char* text) +{ + Evas_Object *notify; + + notify = elm_notify_add(parent); + ivug_retv_if(notify == NULL, NULL); + elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_BOTTOM); + evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(notify, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_smart_callback_add(notify, "timeout", _ivug_selectioninfo_timeout_cb, NULL); + elm_notify_timeout_set(notify, NOTIFY_TIMEOUT); + + int rot_angle = gGetRotationDegree(); + + Evas_Object* layout = elm_layout_add(parent); + +#ifdef USE_CUSTOM_STYLE + elm_object_theme_set(layout, gGetSystemTheme()); + + if ( (rot_angle == 0) || (rot_angle == 180) ) + { + elm_layout_theme_set(layout, "standard", "selectioninfo", "vertical/bottom_86"); + } + else + { + elm_layout_theme_set(layout, "standard", "selectioninfo", "horizontal/bottom_64"); + } +#endif + + 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); + elm_object_content_set(notify, layout); + edje_object_part_text_set(_EDJ(layout), "elm.text", text); + + evas_object_event_callback_add(notify, EVAS_CALLBACK_RESIZE, _on_resize, NULL); + + evas_object_show(notify); + + return notify; +} + +Evas_Object* +ivug_notify_create(Evas_Object* parent, const char* text) +{ + Evas_Object *notify; + + notify = elm_notify_add(parent); + ivug_retv_if(notify == NULL, NULL); + elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_BOTTOM); + evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(notify, EVAS_HINT_FILL, EVAS_HINT_FILL); + + int rot_angle = gGetRotationDegree(); + + Evas_Object* layout = elm_layout_add(parent); + +#ifdef USE_CUSTOM_STYLE + elm_object_theme_set(layout, gGetSystemTheme()); + + if ( (rot_angle == 0) || (rot_angle == 180) ) + { + elm_layout_theme_set(layout, "standard", "selectioninfo", "vertical/bottom_86"); + } + else + { + elm_layout_theme_set(layout, "standard", "selectioninfo", "horizontal/bottom_64"); + } +#endif + + 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); + elm_object_content_set(notify, layout); + edje_object_part_text_set(_EDJ(layout), "elm.text", text); + + evas_object_event_callback_add(notify, EVAS_CALLBACK_RESIZE, _on_resize, NULL); + + evas_object_show(notify); + + return notify; +} + diff --git a/main/src/control/ivug-selectioninfo.h b/main/src/control/ivug-selectioninfo.h new file mode 100755 index 0000000..ceb01a4 --- /dev/null +++ b/main/src/control/ivug-selectioninfo.h @@ -0,0 +1,33 @@ +/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.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 __IVUG_SELECTIONINFO_H__ +#define __IVUG_SELECTIONINFO_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/* time out applied */ +Evas_Object * ivug_selectioninfo_create(Evas_Object* parent, const char* contents); + +Evas_Object * ivug_notify_create(Evas_Object* parent, const char* text); + +#ifdef __cplusplus +} +#endif + +#endif // __IVUG_SELECTIONINFO_H__ diff --git a/main/src/control/ivug-setas.cpp b/main/src/control/ivug-setas.cpp new file mode 100755 index 0000000..18db6fe --- /dev/null +++ b/main/src/control/ivug-setas.cpp @@ -0,0 +1,321 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.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.tizenopensource.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 "ivug-common.h" + +#include "ivug-debug.h" +#include "ivug-util.h" +#include "ivug-image.h" + +#include "ivug-setas.h" + +/* + Used for storing cropped image. +*/ +#define IVUG_HOME_SCREEN_TEMP_PATH DATA_PATH"/.homescreen_tmp.jpg" +#define IVUG_LOCK_SCREEN_TEMP_PATH DATA_PATH"/.lockscreen_tmp.jpg" + + +static Eina_Bool _crop_image(Evas_Object *photocam, Evas_Coord_Rectangle *rect, const char *save_file, const char *option) +{ + if (ivug_remove_file(save_file) == false) + { + MSG_SETAS_ERROR( "Delete file %s: failed", save_file); + return EINA_FALSE; + } + + Evas_Object *ret_image = NULL; + + ret_image = ivug_image_region_image_get(photocam, rect->x, rect->y, rect->w , rect->h); + + if(ret_image == NULL) + { + MSG_SETAS_ERROR("Region get faied."); + return EINA_FALSE; + } + + if (evas_object_image_save(ret_image, save_file, NULL, option) == EINA_FALSE) + { + MSG_SETAS_ERROR("evas_object_image_save error. %s", save_file); + MSG_SETAS_ERROR("setas image save faied."); + evas_object_del(ret_image); + return EINA_FALSE; + } + + evas_object_del(ret_image); + + return EINA_TRUE; +} + + +static Eina_Bool _photocam_image_save(Evas_Object *photocam, Evas_Coord_Rectangle *rect, const char* tmp_file, const char* final_file) +{ +//2. Crop image and save it as tmp file + Eina_Bool ret; + + if ( tmp_file == NULL ) + { + if (ivug_remove_file(final_file) == false) // Remove dest file + { + MSG_SETAS_ERROR( "Delete file %s failed", final_file); + goto error; + } + + ret = _crop_image(photocam, rect, final_file, "quality=100 compress=9"); + if(ret == EINA_FALSE) + { + MSG_SETAS_ERROR("crop image failed!"); + goto error; + } + + } + else + { + // save ½ÇÆнà ÇöÀçÀÇ image¸¦ º¸È£Çϱâ À§ÇØ ¸ÕÀú tmp¿¡ ÀúÀåÇÑ ´ÙÀ½ rename ÇÑ´Ù. + ret = _crop_image(photocam, rect, tmp_file, "quality=100 compress=9"); + if(ret == EINA_FALSE) + { + MSG_SETAS_ERROR("crop image failed!"); + goto error; + } + + //3. Delete the lockscreen file if exist + if (ivug_remove_file(final_file) == false) + { + MSG_SETAS_ERROR( "Delete file %s failed", final_file); + goto error; + } + + //4. rename the tmp file to lock screen file + if(ivug_rename_file(tmp_file, final_file) == false) + { + MSG_SETAS_ERROR( "Rename file %s to %s failed", tmp_file, final_file); + goto error; + } + } + + return EINA_TRUE; +error: + + if(ivug_remove_file(tmp_file) == false) + { + MSG_SETAS_ERROR( "Delete file %s failed", tmp_file); + } + + return EINA_FALSE; +} + +Eina_Bool +_ivug_setas_save_home_screen(Evas_Object *photocam, Evas_Coord_Rectangle *rect, const char *dest) +{ + MSG_SETAS_HIGH("Change Home Screen"); + + Eina_Bool ret = EINA_FALSE; + + ret = _photocam_image_save(photocam, rect, IVUG_HOME_SCREEN_TEMP_PATH, dest); + + if(ret == EINA_FALSE) + { + MSG_SETAS_ERROR("Create screen file failed"); + return EINA_FALSE; + } + + return EINA_TRUE; +} + +Eina_Bool +_ivug_setas_save_lock_screen(Evas_Object *photocam, Evas_Coord_Rectangle *rect, const char *dest) +{ + MSG_SETAS_HIGH("Change Lock Screen"); + + Eina_Bool ret = EINA_FALSE; + + ret = _photocam_image_save(photocam, rect, IVUG_LOCK_SCREEN_TEMP_PATH, dest); + + if(ret == EINA_FALSE) + { + MSG_SETAS_ERROR( "Create screen file failed"); + return EINA_FALSE; + } + + return EINA_TRUE; +} + +Eina_Bool +_ivug_setas_save_homenlock_screen(Evas_Object *photocam, Evas_Coord_Rectangle *rect, const char *home, const char *lock) +{ + MSG_SETAS_HIGH("Change Home&Lock Screen"); + +// Set homescreen image + Eina_Bool ret = EINA_FALSE; + + ret = _photocam_image_save(photocam, rect, IVUG_HOME_SCREEN_TEMP_PATH, home); + + if(ret == EINA_FALSE) + { + MSG_SETAS_ERROR( "Create screen file failed"); + return EINA_FALSE; + } + + if (ivug_remove_file(IVUG_LOCK_SCREEN_TEMP_PATH) == false) + { + MSG_SETAS_ERROR( "Detele file %s: failed", IVUG_LOCK_SCREEN_TEMP_PATH); + return EINA_FALSE; + } + +// Make a copy from home screen to lock screen + if( ecore_file_cp(home, IVUG_LOCK_SCREEN_TEMP_PATH) == EINA_FALSE) + { + MSG_SETAS_ERROR( "File copy failed"); + return EINA_FALSE; + } + + if(ivug_rename_file(IVUG_LOCK_SCREEN_TEMP_PATH, lock) == false) + { + MSG_SETAS_ERROR( "Rename file %s to %s failed", IVUG_LOCK_SCREEN_TEMP_PATH, lock ); + if(ivug_remove_file(IVUG_LOCK_SCREEN_TEMP_PATH)== false) + { + MSG_SETAS_ERROR( "delete tmp lock file failed %s", IVUG_LOCK_SCREEN_TEMP_PATH); + } + + return EINA_FALSE; + } + + sync(); //sync copied file. + + return EINA_TRUE; +} + + +#if 0 +static Eina_Bool +_ivug_setas_view_create_croped_image(Evas_Object *photocam, const char *save_file, + Evas_Coord_Rectangle rect, int width, int height, bool bFreeSize) +{ + IV_ASSERT(photocam != NULL); + IV_ASSERT(save_file != NULL); + + if(bFreeSize == true) + { + width = rect.w; + height = rect.h; + } + + if(width <= 0 || height <= 0) + { + MSG_SETAS_ERROR("input size parameter is invalid, w = %d, h = %d", width, height); + return EINA_FALSE; + } + + Evas_Object *ret_image = NULL; + + MSG_SETAS_HIGH("SCissorbox Rect:(%d,%d,%d,%d) Final=(%d,%d)", rect.x, rect.y, rect.w, rect.h, width, height); + + ret_image = ivug_image_region_image_get(photocam, rect.x, rect.y, rect.w, rect.h); + if(ret_image == NULL) + { + MSG_SETAS_ERROR("Region get faied."); + return EINA_FALSE; + } + + if (evas_object_image_save(ret_image, save_file, NULL, "quality=100 compress=9") == EINA_FALSE) + { + MSG_SETAS_ERROR("evas_object_image_save error. %s", save_file); + evas_object_del(ret_image); + return EINA_FALSE; + } + else + { + int fd = open(save_file, O_RDONLY); + if(fd < 0) + { + MSG_SETAS_ERROR("%s open error[%d]", save_file, fd); + evas_object_del(ret_image); + return EINA_FALSE; + } + fsync(fd); + int ret = close(fd); + if(ret < 0) + { + MSG_SETAS_ERROR("%s open error[%d]", save_file, ret); + } + } + + evas_object_del(ret_image); + + return EINA_TRUE; +} + + +static void +_ivug_setas_save_callerimage(Evas_Object *photocam, Evas_Coord_Rectangle *rect, char *filepath) +{ + MSG_SETAS_HIGH("Save CallerID"); + + char* save_file = SET_AS_CALL_ID_PATH; + + Evas_Coord_Rectangle box_rect; + + ivug_scissorbox_region_get(pSetAsView->select_box, &(box_rect.x), &(box_rect.y), &(box_rect.w), &(box_rect.h)); + + Eina_Bool crop_sel_ret = _ivug_setas_view_create_croped_image(photocam, + save_file, box_rect, pSetAsView->box_width, pSetAsView->box_height, pSetAsView->bFreeSize); + if(crop_sel_ret == EINA_FALSE) + { + MSG_SETAS_ERROR( "Crop selector image failed!"); + } + + const char *lcd_file = SET_AS_CALL_ID_LCD_PATH; // ????? + + Eina_Bool crop_lcd_ret = EINA_FALSE; + + crop_lcd_ret = _ivug_setas_view_create_fit_image(pSetAsView->layout, pSetAsView->photocam, lcd_file); + if(crop_lcd_ret == EINA_FALSE) + { + MSG_SETAS_ERROR( "Crop lcd image failed!"); + } + + if(pSetAsView->mode == IVUG_SETAS_UG || pSetAsView->mode == IVUG_SETAS_APPSVC) + { + if ( crop_lcd_ret == EINA_TRUE && crop_sel_ret == EINA_TRUE ) + { + _ivug_setas_view_send_result(gGetUGHandle(), "crop_image_path", save_file, "image_path", lcd_file); + } + } +} +#endif + +Eina_Bool +_ivug_setas_save_cropimage(Evas_Object *photocam, Evas_Coord_Rectangle *rect, const char *filepath) +{ + MSG_SETAS_HIGH("Save Cropped"); + + Eina_Bool ret = EINA_FALSE; + + ret = _photocam_image_save(photocam, rect, NULL, filepath); + + if(ret == EINA_FALSE) + { + MSG_SETAS_ERROR( "Create cropimage file failed"); + return EINA_FALSE; + } + + return EINA_TRUE; +} + + diff --git a/main/src/control/ivug-setas.h b/main/src/control/ivug-setas.h new file mode 100755 index 0000000..9564954 --- /dev/null +++ b/main/src/control/ivug-setas.h @@ -0,0 +1,42 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.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.tizenopensource.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 __IVUG_SETAS_H__ +#define __IVUG_SETAS_H__ + + +#ifdef __cplusplus +extern "C" { +#endif + +Eina_Bool +_ivug_setas_save_home_screen(Evas_Object *photocam, Evas_Coord_Rectangle *rect, const char *dest); + +Eina_Bool +_ivug_setas_save_lock_screen(Evas_Object *photocam, Evas_Coord_Rectangle *rect, const char *dest); + +Eina_Bool +_ivug_setas_save_homenlock_screen(Evas_Object *photocam, Evas_Coord_Rectangle *rect, const char *home, const char *lock); + +Eina_Bool +_ivug_setas_save_cropimage(Evas_Object *photocam, Evas_Coord_Rectangle *rect, const char *filepath); + +#ifdef __cplusplus +} +#endif + +#endif // __IVUG_SETAS_H__ + diff --git a/main/src/control/ivug-widget.c b/main/src/control/ivug-widget.c new file mode 100755 index 0000000..502a13c --- /dev/null +++ b/main/src/control/ivug-widget.c @@ -0,0 +1,215 @@ +/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.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 "ivug-common.h" +#include "ivug-widget.h" + +#include <ui-gadget-module.h> + +#include <Elementary.h> + +static void _on_obj_deleted(void * data, Evas * e, Evas_Object * obj, void * event_info) +{ + char *szMsg = (char *)data; + IV_ASSERT(szMsg != NULL); + + MSG_MAIN_HIGH("On Object deleted. %s", szMsg); + + free(szMsg); +} + +void ivug_on_obj_deleted(Evas_Object* obj, const char *msg, const char *func, int line) +{ + static char buf[1024]; + + sprintf(buf, "%s(L%d):%s", func, line, msg); + + evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, _on_obj_deleted, strdup(buf)); +} + +Evas_Object* ivug_bg_add(Evas_Object* parent, int r, int g, int b) +{ + IV_ASSERT(parent != NULL); + + Evas_Object *bg = elm_bg_add(parent); + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL); + +// elm_win_resize_object_add(parent, bg); + + elm_bg_color_set(bg, r, g, b); + + evas_object_show(bg); + + return bg; +} + +Evas_Object * +ivug_layout_add(Evas_Object *parent, const char *edj, const char *group) +{ + IV_ASSERT(parent != NULL); + + Evas_Object *layout; + + layout = elm_layout_add(parent); + + if ( layout == NULL ) + { + MSG_SETAS_ERROR("Cannot create layout"); + return NULL; + } + + if (elm_layout_file_set(layout, edj, group) == EINA_FALSE) + { + MSG_SETAS_ERROR("edj loading fail, filepath=%s Group=%s", edj, group); + evas_object_del(layout); + return NULL; + } + + evas_object_size_hint_expand_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_fill_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + +#ifdef USE_WIN_AS_PARENT + elm_win_resize_object_add( ug_get_window(), layout); +#else + Evas_Coord x, y, w, h; + evas_object_geometry_get(parent, &x, &y, &w, &h); + + evas_object_move(layout, x, y); + evas_object_resize(layout, w, h); +#endif + + return layout; +} + +Evas_Object* +ivug_default_layout_add( Evas_Object *win) +{ + IV_ASSERT(win != NULL); + + Evas_Object *layout; + layout = elm_layout_add(win); + + if ( layout == NULL ) + { + MSG_SETAS_ERROR("Cannot create layout"); + return NULL; + } + + Eina_Bool ret = EINA_FALSE; + + const char *profile = elm_config_profile_get(); + if (!strcmp(profile,"mobile")) + { + ret = elm_layout_theme_set(layout, "layout", "application", "default"); + MSG_SETAS_HIGH("layout/application/default"); + } + else if (!strcmp(profile,"desktop")) + { + ret = elm_layout_theme_set(layout, "layout", "application", "noindicator"); + MSG_SETAS_HIGH("layout/application/noindicator"); + } + + if (ret == EINA_FALSE) + { + MSG_SETAS_ERROR("theme set fail"); + evas_object_del(layout); + return NULL; + } + + evas_object_size_hint_expand_set( layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_fill_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL ); + +#ifdef USE_WIN_AS_PARENT + elm_win_resize_object_add( ug_get_window(), layout); +#else + Evas_Coord x, y, w, h; + evas_object_geometry_get(parent, &x, &y, &w, &h); + + evas_object_move(layout, x, y); + evas_object_resize(layout, w, h); +#endif + + evas_object_show(layout); + return layout; +} + + +Evas_Object *ivug_button_add(Evas_Object *parent, const char *style, const char *caption, Evas_Object *icon, Evas_Smart_Cb pFunc, const void * data ) +{ + IV_ASSERT(parent != NULL); + + Evas_Object *btn; + + btn = elm_button_add(parent); + if ( btn == NULL ) + { + return NULL; + } + + if ( style ) + elm_object_style_set(btn, style); + + if ( caption ) + elm_object_text_set(btn, caption); + + if ( icon ) + elm_object_part_content_set(btn, "icon", icon); + + elm_object_focus_allow_set(btn, EINA_FALSE); + evas_object_propagate_events_set(btn, EINA_FALSE); + + evas_object_smart_callback_add(btn, "clicked", pFunc, (void*)data); + + return btn; +} + +Evas_Object *ivug_icon_add(Evas_Object *parent, const char *edjname, const char *groupname) +{ + Evas_Object *icon; + + icon = elm_icon_add(parent); + + if ( elm_icon_file_set(icon, edjname, groupname) == EINA_FALSE) + { + MSG_IVUG_ERROR("Cannot file set. EDJ=%s Group=%s", edjname, groupname); + evas_object_del(icon); + return NULL; + } + + evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); + elm_icon_resizable_set(icon, 1, 1); + evas_object_size_hint_expand_set(icon, 1, 1); + + return icon; +} + +Evas_Object *ivug_controlbar_add(Evas_Object *parent, const char *style) +{ + Evas_Object *toolbar = elm_toolbar_add(parent); + if (!toolbar) + { + MSG_MAIN_ERROR("tool bar failed"); + return NULL; + } + elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_EXPAND); + if(style) + elm_object_style_set(toolbar, style); + //elm_toolbar_homogeneous_set(toolbar, EINA_FALSE); + + return toolbar; +} + diff --git a/main/src/control/ivug-widget.h b/main/src/control/ivug-widget.h new file mode 100755 index 0000000..9433e46 --- /dev/null +++ b/main/src/control/ivug-widget.h @@ -0,0 +1,61 @@ +/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.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 __IVUG_WIDGET_H__ +#define __IVUG_WIDGET_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + Internal use only... use macro DELETE_LOG instead +*/ +void ivug_on_obj_deleted(Evas_Object* obj, const char *msg, const char *func, int line); + + +#define DELETE_NOTIFY(obj) \ + ivug_on_obj_deleted(obj, #obj, __func__, __LINE__) + +/* + Create elm_bg with color - r,g,b +*/ +Evas_Object * +ivug_bg_add(Evas_Object* parent, int r, int g, int b); + +Evas_Object * +ivug_layout_add(Evas_Object *win, const char *edjname, const char *groupname); + +Evas_Object* +ivug_default_layout_add( Evas_Object *win); + +Evas_Object * +ivug_button_add(Evas_Object *parent, const char *style, const char *caption, Evas_Object *icon, Evas_Smart_Cb pFunc, const void *data ); + +Evas_Object * +ivug_icon_add(Evas_Object *parent, const char *edjname, const char *groupname); + +Evas_Object * +ivug_controlbar_add(Evas_Object *parent, const char *style); + + +#ifdef __cplusplus +} +#endif + + +#endif // __IVUG_WIDGET_H__ + |