From 8b42d4bb33943903b7160bb963bf7e7c6824e9ef Mon Sep 17 00:00:00 2001 From: Kim Kibum Date: Fri, 8 Jun 2012 14:54:16 +0900 Subject: apply FSL(Flora Software License) --- main/src/control/ivug-main.c | 258 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 258 insertions(+) create mode 100755 main/src/control/ivug-main.c (limited to 'main/src/control/ivug-main.c') diff --git a/main/src/control/ivug-main.c b/main/src/control/ivug-main.c new file mode 100755 index 0000000..3efb9c8 --- /dev/null +++ b/main/src/control/ivug-main.c @@ -0,0 +1,258 @@ +/* + * 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-main.h" +#include "ivug-data.h" +#include "ivug-util.h" + + +#include // ug_destroy_me +#include + +#define MAX_INSTALNCE (5) + +typedef struct +{ + struct ui_gadget *ug; // ug handle + + Evas_Object *parent_win; +// EFL theme + Elm_Theme *th; + +// Window Geometry + int win_w, win_h; //size + + MediaSvcHandle *media_svc_hadle; + +} 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; +} + +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; + +} + +struct ui_gadget * +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; +} + +MediaSvcHandle * +gGetMediaSVCHandle(void) +{ + AppData *ugContext; + ugContext = eina_list_data_get(ContextList); + + IV_ASSERT(ugContext != NULL); + + return ugContext->media_svc_hadle; +} + +#define IVUG_NAVIFRAME_NAME EDJ_PATH"/ivug-naviframe.edj" +#define IVUG_TOOLLBAR_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" + +static char *edj[] = { + IVUG_NAVIFRAME_NAME, + IVUG_TOOLLBAR_NAME, + IVUG_BUTTON_NAME, + IVUG_SELECTION_INFO_NAME, + IVUG_GENLIST, + NULL, +}; + +bool +ivug_main_init(struct ui_gadget *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(); + +//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); + +//media browser service. + int err = media_svc_connect(&(Context->media_svc_hadle)); + if (err == MB_SVC_ERROR_NONE) + { + bindtextdomain(IVUG_TEXT_DOMAIN, IVUG_LOCALEDIR); //bind text domain + return TRUE; + } + +/**** Error routine ****/ + MSG_SDATA_WARN("media service init error=%d", err); + + 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_main_deinit(struct ui_gadget *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; + } + } + + //media browser service. + int err = media_svc_disconnect(Context->media_svc_hadle); + if (err != MB_SVC_ERROR_NONE) + { + MSG_SDATA_WARN("media service finalize error=%d", err); + // go through + } + else + { + MSG_SDATA_HIGH("MInfo finalized"); + } + + 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 true; +} + + + + -- cgit v1.2.3