2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.tizenopensource.org/license
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "gl-nocontents.h"
18 #include "gl-gridview.h"
19 #include "gl-listview.h"
20 #include "gl-controlbar.h"
21 #include "gl-ui-util.h"
23 #include "gl-strings.h"
29 Evas_Object *_gl_nocontents_create(void *data)
32 gl_appdata *ad = (gl_appdata *)data;
33 Evas_Object *noc_lay = NULL;
34 char label_str[GL_POPUP_DESC_LEN_MAX] = { 0, };
36 int grid_mode = ad->gridinfo.grid_view_mode;
39 snprintf(label_str, sizeof(label_str), "%s",
40 (char *)(GL_STR_NO_ITEMS));
43 snprintf(label_str, sizeof(label_str), "%s",
44 (char *)(GL_STR_NO_VIDEOS));
47 snprintf(label_str, sizeof(label_str), "%s",
48 (char *)(GL_STR_NO_IMAGES));
51 snprintf(label_str, sizeof(label_str), "%s",
52 (char *)(GL_STR_NO_ALBUMS));
55 snprintf(label_str, sizeof(label_str), "%s",
56 (char *)(GL_STR_NO_CONTENTS));
60 gl_dbg("Nocontents label: %s", label_str);
61 /* Full view nocontents */
62 noc_lay = elm_layout_add(ad->maininfo.naviframe);
63 GL_CHECK_NULL(noc_lay);
64 elm_object_part_text_set(noc_lay, GL_NOCONTENTS_TEXT, label_str);
65 elm_layout_theme_set(noc_lay, "layout", "nocontents", "gallery");
71 * Update label of Nocontents.
73 bool _gl_nocontents_update_label(Evas_Object *noc, const char *new_label)
75 GL_CHECK_VAL(new_label, -1);
76 GL_CHECK_VAL(noc, -1);
77 const char *label = NULL;
79 label = elm_object_part_text_get(noc, GL_NOCONTENTS_TEXT);
80 GL_CHECK_VAL(label, -1);
81 gl_dbg("Nocontents label: %s", label);
82 /* Update label if they're different */
83 if (g_strcmp0(label, GL_STR_NO_ALBUMS)) {
84 gl_dbgW("Update nocontents label!");
85 elm_object_part_text_set(noc, GL_NOCONTENTS_TEXT, new_label);
92 * Show Nocontents in All/Images/Videos segment.
94 bool _gl_nocontents_show(void *data)
97 gl_appdata *ad = (gl_appdata *)data;
98 bool b_video_exist = false;
99 bool b_image_exist = false;
100 int seg_mode = ad->maininfo.seg_mode;
101 gl_item *gitem = NULL;
104 int view_mode = gl_get_view_mode(ad);
105 /* Get all medias count of current album */
106 int cnt = ad->maininfo.medias_cnt;
108 if (seg_mode == GL_CTRL_SEG_VIDEOS ||
109 seg_mode == GL_CTRL_SEG_IMAGES) {
110 /* check in video or image segment. */
111 for (i = 1; i <= cnt; i++) {
112 _gl_data_get_item_by_index(ad, i, false, &gitem);
113 if (gitem == NULL || gitem->item == NULL) {
114 gl_dbgE("gitem == NULL || gitem->item == NULL");
118 if (seg_mode == GL_CTRL_SEG_VIDEOS && !b_video_exist &&
119 gitem->item->type == MEDIA_CONTENT_TYPE_VIDEO) {
120 b_video_exist = true;
122 } else if (seg_mode == GL_CTRL_SEG_IMAGES &&
124 gitem->item->type == MEDIA_CONTENT_TYPE_IMAGE) {
125 b_image_exist = true;
131 gl_dbg("video file exists->%d, image file exists->%d",
132 b_video_exist, b_image_exist);
133 if (seg_mode == GL_CTRL_SEG_VIDEOS && !b_video_exist) {
134 if (view_mode == GL_VIEW_VIDEOLIST_EDIT) {
135 gl_dbg("In edit mode, change to normal view.");
136 gl_ui_edit_cancel(ad);
139 gl_dbg("None video files, show nocontents...");
141 } else if (seg_mode == GL_CTRL_SEG_IMAGES && !b_image_exist) {
142 if (view_mode == GL_VIEW_THUMBS_EDIT) {
143 gl_dbg("In edit mode, change to normal view.");
144 gl_ui_edit_cancel(ad);
147 gl_dbg("None image files, show nocontents...");
148 Evas_Object *noc = _gl_nocontents_create(ad);
149 if (ad->gridinfo.images_view) {
150 evas_object_del(ad->gridinfo.images_view);
151 ad->gridinfo.images_view = NULL;
153 ad->gridinfo.images_view = noc;
154 ad->gridinfo.images_nocontents = noc;
155 elm_object_part_content_unset(ad->gridinfo.layout,
157 evas_object_hide(ad->listinfo.videos_view);
158 evas_object_hide(ad->gridinfo.all_view);
159 evas_object_show(ad->gridinfo.images_view);
160 elm_object_part_content_set(ad->gridinfo.layout,
162 ad->gridinfo.images_view);
163 _gl_ctrl_disable_toolbar_item(ad, true, GL_NAVI_THUMBS,