Merge "[Title] hiding the guide text when the input field is not empty." into 2.0_beta
[profile/ivi/org.tizen.browser.git] / src / browser-history / browser-history-layout.cpp
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
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
7  *
8  *    http://www.tizenopensource.org/license
9  *
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.
15  *
16  */
17
18
19 #include "browser-add-to-bookmark-view.h"
20 #include "browser-view.h"
21 #include "browser-history-layout.h"
22
23 Date::Date() : day(0), month(0), year(0) {}
24
25 Date::Date(Date &date)
26 {
27         this->day = date.day;
28         this->month = date.month;
29         this->year = date.year;
30 }
31
32 void Date::operator=(Date &date)
33 {
34         this->day = date.day;
35         this->month = date.month;
36         this->year = date.year;
37 }
38
39 bool Date::operator==(Date &date)
40 {
41         return (this->day == date.day && this->month == date.month && this->year == date.year);
42 }
43
44 bool Date::operator!=(Date &date)
45 {
46         return (this->day != date.day || this->month != date.month || this->year != date.year);
47 }
48
49 Browser_History_Layout::Browser_History_Layout(void)
50 :       m_history_genlist(NULL)
51         ,m_edit_mode_select_all_layout(NULL)
52         ,m_edit_mode_select_all_check_button(NULL)
53         ,m_content_box(NULL)
54         ,m_no_history_label(NULL)
55         ,m_current_sweep_item(NULL)
56         ,m_processing_popup_timer(NULL)
57         ,m_processed_it(NULL)
58         ,m_processed_count(0)
59         ,m_total_item_count(0)
60         ,m_processing_popup(NULL)
61         ,m_processing_popup_layout(NULL)
62         ,m_processing_progress_bar(NULL)
63         ,m_select_all_check_value(EINA_FALSE)
64         ,m_searchbar_layout(NULL)
65         ,m_searched_history_genlist(NULL)
66         ,m_no_content_search_result(NULL)
67         ,m_searchbar(NULL)
68         ,m_delete_confirm_popup(NULL)
69         ,m_is_bookmark_on_off_icon_clicked(EINA_FALSE)
70 {
71         BROWSER_LOGD("[%s]", __func__);
72 }
73
74 Browser_History_Layout::~Browser_History_Layout(void)
75 {
76         BROWSER_LOGD("[%s]", __func__);
77         hide_notify_popup();
78
79         for(int i = 0 ; i < m_history_list.size() ; i++ ) {
80                 if (m_history_list[i])
81                         delete m_history_list[i];
82         }
83         m_history_list.clear();
84
85         for(int i = 0 ; i < m_history_date_label_list.size() ; i++ ) {
86                 if (m_history_date_label_list[i])
87                         free(m_history_date_label_list[i]);
88         }
89         m_history_date_label_list.clear();
90
91         for(int i = 0 ; i < m_searched_history_date_label_list.size() ; i++ ) {
92                 if (m_searched_history_date_label_list[i])
93                         free(m_searched_history_date_label_list[i]);
94         }
95         m_searched_history_date_label_list.clear();
96
97         for(int i = 0 ; i < m_searched_history_item_list.size() ; i++ ) {
98                 if (m_searched_history_item_list[i])
99                         delete m_searched_history_item_list[i];
100         }
101         m_searched_history_item_list.clear();
102
103         if (m_delete_confirm_popup)
104                 evas_object_del(m_delete_confirm_popup);
105
106 }
107
108 Eina_Bool Browser_History_Layout::init(void)
109 {
110         BROWSER_LOGD("[%s]", __func__);
111         return _create_main_layout();
112 }
113
114 Eina_Bool Browser_History_Layout::_show_searched_history(const char *search_text)
115 {
116         BROWSER_LOGD("search_text = [%s]", search_text);
117
118         for(int i = 0 ; i < m_searched_history_item_list.size() ; i++ ) {
119                 if (m_searched_history_item_list[i])
120                         delete m_searched_history_item_list[i];
121         }
122         m_searched_history_item_list.clear();
123
124         for(int i = 0 ; i < m_searched_history_date_label_list.size() ; i++ ) {
125                 if (m_searched_history_date_label_list[i])
126                         free(m_searched_history_date_label_list[i]);
127         }
128         m_searched_history_date_label_list.clear();
129
130         if (!search_text || !strlen(search_text)) {
131                 if (m_searched_history_genlist || m_no_content_search_result) {
132                         elm_box_unpack_all(m_content_box);
133                         elm_box_pack_start(m_content_box, m_history_genlist);
134                         evas_object_show(m_history_genlist);
135
136                         if (m_searched_history_genlist) {
137                                 evas_object_del(m_searched_history_genlist);
138                                 m_searched_history_genlist = NULL;
139                         }
140
141                         if (m_no_content_search_result) {
142                                 evas_object_del(m_no_content_search_result);
143                                 m_no_content_search_result = NULL;
144                         }
145
146                         if (m_history_list.size() == 0) {
147                                 if (m_no_history_label) {
148                                         elm_box_unpack_all(m_content_box);
149                                         elm_box_pack_start(m_content_box, m_no_history_label);
150                                 }
151                         }
152
153                         return EINA_TRUE;
154                 }
155         }
156
157         Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
158         while (it) {
159                 Browser_History_DB::history_item *item = NULL;
160                 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
161                 if (item && elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
162                         if (item->url.find(search_text) != string::npos || item->title.find(search_text) != string::npos) {
163                                 Browser_History_DB::history_item *searched_item = NULL;
164                                 searched_item = new(nothrow) Browser_History_DB::history_item;
165                                 searched_item->id = item->id;
166                                 searched_item->url = item->url;
167                                 searched_item->title = item->title;
168                                 searched_item->date = item->date;
169                                 searched_item->is_delete = item->is_delete;
170                                 searched_item->user_data = item->user_data;
171                                 m_searched_history_item_list.push_back(searched_item);
172                         }
173                 }
174                 it = elm_genlist_item_next_get(it);
175         }
176
177         if (m_searched_history_item_list.size()) {
178                 if (m_no_content_search_result) {
179                         evas_object_del(m_no_content_search_result);
180                         m_no_content_search_result = NULL;
181                 }
182
183                 if (!m_searched_history_genlist) {
184                         m_searched_history_genlist = _create_history_genlist();
185                         if (!m_searched_history_genlist) {
186                                 BROWSER_LOGE("_create_history_genlist failed");
187                                 return EINA_FALSE;
188                         }
189                 }
190
191                 elm_genlist_clear(m_searched_history_genlist);
192
193                 Date date;
194                 Date last_date;
195                 for(int i = 0 ; i < m_searched_history_item_list.size() ; i++) {
196                         sscanf(m_searched_history_item_list[i]->date.c_str(), "%d-%d-%d", &date.year, &date.month, &date.day);
197                         m_searched_history_item_list[i]->user_data = (void *)this;
198                         if (last_date != date) {
199                                 last_date = date;
200                                 char *labe_item = strdup(m_searched_history_item_list[i]->date.c_str());
201                                 if (!labe_item) {
202                                         BROWSER_LOGE("strdup failed");
203                                         return EINA_FALSE;
204                                 }
205                                 m_searched_history_date_label_list.push_back(labe_item);
206                                 it = elm_genlist_item_append(m_searched_history_genlist, &m_history_group_title_class,
207                                                                 labe_item, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
208
209                                 elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
210                         }
211                         elm_genlist_item_append(m_searched_history_genlist, &m_history_genlist_item_class,
212                                                 m_searched_history_item_list[i], it, ELM_GENLIST_ITEM_NONE,
213                                                 __history_item_clicked_cb, this);
214                 }
215
216                 elm_box_unpack_all(m_content_box);
217                 evas_object_hide(m_history_genlist);
218                 elm_box_pack_start(m_content_box, m_searched_history_genlist);
219                 evas_object_show(m_searched_history_genlist);
220         } else {
221                 BROWSER_LOGD("show no content");
222                 if (m_no_content_search_result)
223                         evas_object_del(m_no_content_search_result);
224                 m_no_content_search_result = elm_layout_add(m_content_box);
225                 if (!m_no_content_search_result) {
226                         BROWSER_LOGE("elm_layout_add failed");
227                         return EINA_FALSE;
228                 }
229                 elm_layout_theme_set(m_no_content_search_result, "layout", "nocontents", "search");
230                 elm_object_part_text_set(m_no_content_search_result, "elm.text", BR_STRING_NO_SEARCH_RESULT);
231                 evas_object_size_hint_weight_set(m_no_content_search_result, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
232                 evas_object_size_hint_align_set(m_no_content_search_result, EVAS_HINT_FILL, EVAS_HINT_FILL);
233
234                 if (m_searched_history_genlist) {
235                         evas_object_del(m_searched_history_genlist);
236                         m_searched_history_genlist = NULL;
237                 }
238
239                 elm_box_unpack_all(m_content_box);
240                 evas_object_hide(m_history_genlist);
241                 elm_box_pack_start(m_content_box, m_no_content_search_result);
242                 evas_object_show(m_no_content_search_result);
243         }
244
245         return EINA_TRUE;
246 }
247
248 void Browser_History_Layout::__search_delay_changed_cb(void *data, Evas_Object *obj, void *event_info)
249 {
250         const char *search_text = elm_entry_entry_get(obj);
251         BROWSER_LOGD("search_text=[%s]", search_text);
252
253         if (!data || !search_text)
254                 return;
255
256         char *utf8_text = elm_entry_markup_to_utf8(search_text);
257         if (!utf8_text)
258                 return;
259
260         Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
261         if (!elm_entry_is_empty(obj))
262                 elm_object_signal_emit(history_layout->m_searchbar, "elm,state,guidetext,hide", "elm");
263         if (!history_layout->_show_searched_history(utf8_text))
264                 BROWSER_LOGE("_show_searched_history failed");
265
266         free(utf8_text);
267 }
268
269 void Browser_History_Layout::_enable_searchbar_layout(Eina_Bool enable)
270 {
271         if (enable) {
272                 elm_layout_theme_set(m_searchbar_layout, "layout", "application", "searchbar_base");
273
274                 if (!m_searchbar) {
275                         m_searchbar = br_elm_searchbar_add(m_searchbar_layout);
276                         if (!m_searchbar)
277                                 BROWSER_LOGD("br_elm_searchbar_add failed");
278                 }
279
280                 elm_object_part_content_set(m_searchbar_layout, "searchbar", m_searchbar);
281                 evas_object_show(m_searchbar);
282
283                 elm_object_signal_emit(m_searchbar_layout, "elm,state,show,searchbar", "elm");
284
285                 Evas_Object *searchbar_entry = br_elm_searchbar_entry_get(m_searchbar);
286                 elm_entry_input_panel_layout_set(searchbar_entry, ELM_INPUT_PANEL_LAYOUT_URL);
287
288                 evas_object_smart_callback_add(searchbar_entry, "changed", __search_delay_changed_cb, this);
289         } else {
290                 for(int i = 0 ; i < m_searched_history_item_list.size() ; i++ ) {
291                         if (m_searched_history_item_list[i])
292                                 delete m_searched_history_item_list[i];
293                 }
294                 m_searched_history_item_list.clear();
295
296                 for(int i = 0 ; i < m_searched_history_date_label_list.size() ; i++ ) {
297                         if (m_searched_history_date_label_list[i])
298                                 free(m_searched_history_date_label_list[i]);
299                 }
300                 m_searched_history_date_label_list.clear();
301
302                 if (m_searched_history_genlist || m_no_content_search_result) {
303                         elm_box_unpack_all(m_content_box);
304                         elm_box_pack_start(m_content_box, m_history_genlist);
305                         evas_object_show(m_history_genlist);
306
307                         if (m_searched_history_genlist) {
308                                 evas_object_del(m_searched_history_genlist);
309                                 m_searched_history_genlist = NULL;
310                         }
311
312                         if (m_no_content_search_result) {
313                                 evas_object_del(m_no_content_search_result);
314                                 m_no_content_search_result = NULL;
315                         }
316                 }
317
318                 if (m_searchbar) {
319                         elm_object_part_content_unset(m_searchbar_layout, "searchbar");
320                         evas_object_hide(m_searchbar);
321                 }
322
323                 Evas_Object *searchbar_entry = br_elm_searchbar_entry_get(m_searchbar);
324                 evas_object_smart_callback_del(searchbar_entry, "changed", __search_delay_changed_cb);
325
326                 elm_layout_theme_set(m_searchbar_layout, "layout", "application", "noindicator");
327         }
328 }
329
330 void Browser_History_Layout::_set_edit_mode(Eina_Bool edit_mode)
331 {
332         BROWSER_LOGD("[%s]", __func__);
333         Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
334
335         hide_notify_popup();
336
337         _enable_searchbar_layout(!edit_mode);
338
339         if (edit_mode) {
340                 elm_object_style_set(m_bg, "edit_mode");
341
342                 m_edit_mode_select_all_layout = elm_layout_add(m_content_box);
343                 if (!m_edit_mode_select_all_layout) {
344                         BROWSER_LOGE("elm_layout_add failed");
345                         return;
346                 }
347                 elm_layout_theme_set(m_edit_mode_select_all_layout, "genlist", "item", "select_all/default");
348                 evas_object_size_hint_weight_set(m_edit_mode_select_all_layout, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
349                 evas_object_size_hint_align_set(m_edit_mode_select_all_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
350                 evas_object_event_callback_add(m_edit_mode_select_all_layout, EVAS_CALLBACK_MOUSE_DOWN,
351                                                                 __edit_mode_select_all_clicked_cb, this);
352
353                 m_edit_mode_select_all_check_button = elm_check_add(m_edit_mode_select_all_layout);
354                 if (!m_edit_mode_select_all_check_button) {
355                         BROWSER_LOGE("elm_layout_add failed");
356                         return;
357                 }
358                 evas_object_smart_callback_add(m_edit_mode_select_all_check_button, "changed",
359                                                 __edit_mode_select_all_check_changed_cb, this);
360                 evas_object_propagate_events_set(m_edit_mode_select_all_check_button, EINA_FALSE);
361
362                 elm_object_part_content_set(m_edit_mode_select_all_layout, "elm.icon", m_edit_mode_select_all_check_button);
363                 elm_object_text_set(m_edit_mode_select_all_layout, BR_STRING_SELECT_ALL);
364
365                 elm_box_pack_start(m_content_box, m_edit_mode_select_all_layout);
366                 evas_object_show(m_edit_mode_select_all_layout);
367
368                 elm_genlist_decorate_mode_set(m_history_genlist, EINA_TRUE);
369                 elm_genlist_select_mode_set(m_history_genlist, ELM_OBJECT_SELECT_MODE_ALWAYS);
370
371                 bookmark_view->_set_navigationbar_title(BR_STRING_SELECT_HISTORIES);
372
373                 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_EDIT_MODE))
374                         BROWSER_LOGE("_set_controlbar_type HISTORY_VIEW_EDIT_MODE failed");
375         } else {
376                 if (m_edit_mode_select_all_layout) {
377                         elm_box_unpack(m_content_box, m_edit_mode_select_all_layout);
378                         evas_object_del(m_edit_mode_select_all_layout);
379                         m_edit_mode_select_all_layout = NULL;
380                 }
381                 if (m_edit_mode_select_all_check_button) {
382                         evas_object_del(m_edit_mode_select_all_check_button);
383                         m_edit_mode_select_all_check_button = NULL;
384                 }
385                 if (m_no_history_label) {
386                         evas_object_del(m_no_history_label);
387                         m_no_history_label = NULL;
388                 }
389
390                 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
391                 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_DEFAULT))
392                         BROWSER_LOGE("_set_controlbar_type failed");
393
394                 Elm_Object_Item *it = NULL;
395                 Browser_History_DB::history_item *item = NULL;
396                 it = elm_genlist_first_item_get(m_history_genlist);
397                 while(it) {
398                         item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
399                         item->is_delete = EINA_FALSE;
400                         it = elm_genlist_item_next_get(it);
401                 }
402
403                 elm_object_style_set(m_bg, "default");
404                 elm_genlist_decorate_mode_set(m_history_genlist, EINA_FALSE);
405                 elm_genlist_select_mode_set(m_history_genlist, ELM_OBJECT_SELECT_MODE_DEFAULT);
406
407                 bookmark_view->_set_navigationbar_title(BR_STRING_HISTORY);
408
409                 if (m_history_list.size() == 0) {
410                         elm_box_unpack_all(m_content_box);
411                         elm_genlist_clear(m_history_genlist);
412                         evas_object_hide(m_history_genlist);
413
414                         if (m_edit_mode_select_all_layout) {
415                                 evas_object_del(m_edit_mode_select_all_layout);
416                                 m_edit_mode_select_all_layout = NULL;
417                         }
418                         if (m_edit_mode_select_all_check_button) {
419                                 evas_object_del(m_edit_mode_select_all_check_button);
420                                 m_edit_mode_select_all_check_button = NULL;
421                         }
422
423                         m_no_history_label = elm_label_add(m_searchbar_layout);
424                         if (!m_no_history_label) {
425                                 BROWSER_LOGE("elm_label_add failed");
426                                 return;
427                         }
428
429                         std::string text = std::string("<color='#646464'>") + std::string(BR_STRING_NO_HISTORY);
430                         elm_object_text_set(m_no_history_label, text.c_str());
431                         evas_object_show(m_no_history_label);
432                         elm_box_pack_start(m_content_box, m_no_history_label);
433
434                         elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_TRUE);
435                 }
436         }
437 }
438
439 void Browser_History_Layout::_show_selection_info(void)
440 {
441         BROWSER_LOGD("[%s]", __func__);
442         Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
443         int selected_count = 0;
444         int total_count = 0;
445         while(it) {
446                 Browser_History_DB::history_item *item = NULL;
447                 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
448                 if (item && elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
449                         if (item->is_delete)
450                                 selected_count++;
451                         total_count++;
452                 }
453                 it = elm_genlist_item_next_get(it);
454         }
455
456         if (selected_count == 0) {
457                 elm_object_item_disabled_set(m_data_manager->get_bookmark_view()->m_bookmark_delete_controlbar_item, EINA_TRUE);
458                 hide_notify_popup();
459                 return;
460         } else
461                 elm_object_item_disabled_set(m_data_manager->get_bookmark_view()->m_bookmark_delete_controlbar_item, EINA_FALSE);
462
463         if (selected_count == 1) {
464                 show_notify_popup(BR_STRING_ONE_ITEM_SELECTED, 0, EINA_TRUE);
465         } else if (selected_count > 1) {
466                 char *small_popup_text = NULL;
467                 int string_len = strlen(BR_STRING_ITEMS_SELECTED) + 1;
468
469                 small_popup_text = (char *)malloc(string_len * sizeof(char));
470                 memset(small_popup_text, 0x00, string_len);
471
472                 snprintf(small_popup_text, string_len, BR_STRING_ITEMS_SELECTED, selected_count);
473                 show_notify_popup(small_popup_text, 0, EINA_TRUE);
474
475                 if (small_popup_text)
476                         free(small_popup_text);
477                 small_popup_text = 0x00;
478         }
479 }
480
481 void Browser_History_Layout::_show_delete_processing_popup(void)
482 {
483         BROWSER_LOGD("[%s]", __func__);
484         if (m_processing_popup)
485                 evas_object_del(m_processing_popup);
486
487         m_processing_popup = elm_popup_add(m_searchbar_layout);
488         if (!m_processing_popup) {
489                 BROWSER_LOGE("elm_popup_add failed");
490                 return;
491         }
492
493         if (m_processing_popup_layout)
494                 evas_object_del(m_processing_popup_layout);
495         m_processing_popup_layout = elm_layout_add(m_processing_popup);
496         if (!m_processing_popup_layout) {
497                 BROWSER_LOGE("elm_layout_add failed");
498                 return;
499         }
500         if (!elm_layout_file_set(m_processing_popup_layout, BROWSER_EDJE_DIR"/browser-bookmark-view.edj",
501                                                         "browser/popup_center_progressview")) {
502                 BROWSER_LOGE("elm_layout_file_set failed");
503                 return;
504         }
505         evas_object_size_hint_weight_set(m_processing_popup_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
506
507         m_processing_progress_bar = elm_progressbar_add(m_processing_popup);
508         elm_object_style_set(m_processing_progress_bar, "list_progress");
509         elm_progressbar_horizontal_set(m_processing_progress_bar, EINA_TRUE);
510         evas_object_size_hint_align_set(m_processing_progress_bar, EVAS_HINT_FILL, EVAS_HINT_FILL);
511         evas_object_size_hint_weight_set(m_processing_progress_bar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
512         elm_progressbar_value_set(m_processing_progress_bar, 0.0);
513
514         if (m_processing_popup_timer)
515                 ecore_timer_del(m_processing_popup_timer);
516
517         m_processed_count = 0;
518         m_processed_it = elm_genlist_last_item_get(m_history_genlist);
519
520         Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
521         m_total_item_count = 0;
522         while (it) {
523                 Browser_History_DB::history_item *item = NULL;
524                 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
525                 if (item && elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
526                         if(item->is_delete)
527                                 m_total_item_count++;
528                 }
529                 it = elm_genlist_item_next_get(it);
530         }
531
532         m_processing_popup_timer = ecore_timer_add(0.3, __delete_processing_popup_timer_cb, this);
533         evas_object_show(m_processing_progress_bar);
534
535         elm_object_part_content_set(m_processing_popup_layout, "elm.swallow.content", m_processing_progress_bar);
536         edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.title", BR_STRING_PROCESSING);
537         edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.text.left", "");
538         edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.text.right", "");
539
540         elm_object_content_set(m_processing_popup, m_processing_popup_layout);
541
542         Evas_Object *cancel_button = elm_button_add(m_processing_popup);
543         if (!cancel_button) {
544                 BROWSER_LOGE("elm_button_add failed");
545                 return;
546         }
547         elm_object_text_set(cancel_button, BR_STRING_CANCEL);
548         elm_object_part_content_set(m_processing_popup, "button1", cancel_button);
549         evas_object_smart_callback_add(cancel_button, "clicked", __delete_processing_popup_response_cb, this);
550
551         evas_object_show(m_processing_popup);
552 }
553
554 void Browser_History_Layout::__delete_processing_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
555 {
556         BROWSER_LOGD("[%s]", __func__);
557         if (!data)
558                 return;
559
560         Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
561
562         evas_object_del(history_layout->m_processing_popup);
563
564         history_layout->m_processing_progress_bar = NULL;
565         history_layout->m_processed_it = NULL;
566
567         if (history_layout->m_processing_popup_timer) {
568                 ecore_timer_del(history_layout->m_processing_popup_timer);
569                 history_layout->m_processing_popup_timer = NULL;
570         }
571
572         history_layout->show_notify_popup(BR_STRING_DELETED, 3, EINA_TRUE);
573
574         if (history_layout->m_history_list.size() == 0) {
575                 elm_box_unpack_all(history_layout->m_content_box);
576                 elm_genlist_clear(history_layout->m_history_genlist);
577                 evas_object_hide(history_layout->m_history_genlist);
578
579                 if (history_layout->m_edit_mode_select_all_layout) {
580                         evas_object_del(history_layout->m_edit_mode_select_all_layout);
581                         history_layout->m_edit_mode_select_all_layout = NULL;
582                 }
583                 if (history_layout->m_edit_mode_select_all_check_button) {
584                         evas_object_del(history_layout->m_edit_mode_select_all_check_button);
585                         history_layout->m_edit_mode_select_all_check_button = NULL;
586                 }
587
588                 history_layout->m_no_history_label = elm_label_add(history_layout->m_searchbar_layout);
589                 if (!history_layout->m_no_history_label) {
590                         BROWSER_LOGE("elm_label_add failed");
591                         return;
592                 }
593
594                 std::string text = std::string("<color='#646464'>") + std::string(BR_STRING_NO_HISTORY);
595                 elm_object_text_set(history_layout->m_no_history_label, text.c_str());
596                 evas_object_show(history_layout->m_no_history_label);
597                 elm_box_pack_start(history_layout->m_content_box, history_layout->m_no_history_label);
598
599                 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
600                 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_DEFAULT))
601                         BROWSER_LOGE("_set_controlbar_type failed");
602
603                 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_TRUE);
604         }
605 }
606
607 Eina_Bool Browser_History_Layout::__delete_processing_popup_timer_cb(void *data)
608 {
609         BROWSER_LOGD("[%s]", __func__);
610         if (!data)
611                 return ECORE_CALLBACK_CANCEL;
612
613         Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
614         Evas_Object* progress_bar = history_layout->m_processing_progress_bar;
615
616         Eina_Bool check_value = history_layout->m_select_all_check_value;
617
618         double value = elm_progressbar_value_get(progress_bar);
619         if (value >= 1.0) {
620                 __delete_processing_popup_response_cb(history_layout, NULL, NULL);
621
622                 history_layout->m_processing_popup_timer = NULL;
623                 history_layout->show_notify_popup(BR_STRING_DELETED, 3, EINA_TRUE);
624
625                 return ECORE_CALLBACK_CANCEL;
626         }
627
628         while (history_layout->m_processed_it) {
629                 Browser_History_DB::history_item *item = NULL;
630                 item = (Browser_History_DB::history_item *)elm_object_item_data_get(history_layout->m_processed_it);
631                 if (item) {                     
632                         if(item->is_delete
633                             && elm_genlist_item_select_mode_get(history_layout->m_processed_it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
634                                 Eina_Bool ret = m_data_manager->get_history_db()->delete_history(item->id);
635                                 for(int index = 0 ; index < history_layout->m_history_list.size() ; index++) {
636                                         if (history_layout->m_history_list[index]->id == item->id) {
637                                                 delete history_layout->m_history_list[index];
638                                                 history_layout->m_history_list.erase(history_layout->m_history_list.begin() + index);
639                                         }
640                                 }
641
642                                 history_layout->m_processed_count++;
643                                 Elm_Object_Item *it = history_layout->m_processed_it;
644                                 history_layout->m_processed_it = elm_genlist_item_prev_get(history_layout->m_processed_it);
645                                 elm_object_item_del(it);
646                                 elm_genlist_realized_items_update(history_layout->m_history_genlist);
647                         } else
648                                 history_layout->m_processed_it = elm_genlist_item_prev_get(history_layout->m_processed_it);
649                 } else
650                         history_layout->m_processed_it = elm_genlist_item_prev_get(history_layout->m_processed_it);
651
652                 if (history_layout->m_processed_count % 20 == 0)
653                         break;
654         }
655
656         elm_progressbar_value_set(history_layout->m_processing_progress_bar,
657                                 (float)((float)history_layout->m_processed_count / (float)history_layout->m_total_item_count));
658
659         char progress_text[20] = {0, };
660         snprintf(progress_text, sizeof(progress_text) - 1, "%d / %d",
661                         history_layout->m_processed_count, history_layout->m_total_item_count);
662
663         edje_object_part_text_set(elm_layout_edje_get(history_layout->m_processing_popup_layout),
664                                 "elm.text.right", progress_text);
665
666         return ECORE_CALLBACK_RENEW;
667 }
668
669 void Browser_History_Layout::_show_select_processing_popup(void)
670 {
671         BROWSER_LOGD("[%s]", __func__);
672         if (m_processing_popup)
673                 evas_object_del(m_processing_popup);
674
675         m_processing_popup = elm_popup_add(m_searchbar_layout);
676         if (!m_processing_popup) {
677                 BROWSER_LOGE("elm_popup_add failed");
678                 return;
679         }
680
681         if (m_processing_popup_layout)
682                 evas_object_del(m_processing_popup_layout);
683         m_processing_popup_layout = elm_layout_add(m_processing_popup);
684         if (!m_processing_popup_layout) {
685                 BROWSER_LOGE("elm_layout_add failed");
686                 return;
687         }
688         if (!elm_layout_file_set(m_processing_popup_layout, BROWSER_EDJE_DIR"/browser-bookmark-view.edj",
689                                                         "browser/popup_center_progressview")) {
690                 BROWSER_LOGE("elm_layout_file_set failed");
691                 return;
692         }
693         evas_object_size_hint_weight_set(m_processing_popup_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
694
695         m_processing_progress_bar = elm_progressbar_add(m_processing_popup);
696         elm_object_style_set(m_processing_progress_bar, "list_progress");
697         elm_progressbar_horizontal_set(m_processing_progress_bar, EINA_TRUE);
698         evas_object_size_hint_align_set(m_processing_progress_bar, EVAS_HINT_FILL, EVAS_HINT_FILL);
699         evas_object_size_hint_weight_set(m_processing_progress_bar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
700         elm_progressbar_value_set(m_processing_progress_bar, 0.0);
701
702         if (m_processing_popup_timer)
703                 ecore_timer_del(m_processing_popup_timer);
704
705         m_processed_count = 0;
706         m_processed_it = elm_genlist_first_item_get(m_history_genlist);
707
708         m_processing_popup_timer = ecore_timer_add(0.1, __select_processing_popup_timer_cb, this);
709         evas_object_show(m_processing_progress_bar);
710
711         elm_object_part_content_set(m_processing_popup_layout, "elm.swallow.content", m_processing_progress_bar);
712         edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.title", BR_STRING_PROCESSING);
713         edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.text.left", "");
714         edje_object_part_text_set(elm_layout_edje_get(m_processing_popup_layout), "elm.text.right", "");
715
716         elm_object_content_set(m_processing_popup, m_processing_popup_layout);
717
718         Evas_Object *cancel_button = elm_button_add(m_processing_popup);
719         if (!cancel_button) {
720                 BROWSER_LOGE("elm_button_add failed");
721                 return;
722         }
723         elm_object_text_set(cancel_button, BR_STRING_CANCEL);
724         elm_object_part_content_set(m_processing_popup, "button1", cancel_button);
725         evas_object_smart_callback_add(cancel_button, "clicked", __select_processing_popup_response_cb, this);
726
727         evas_object_show(m_processing_popup);
728
729         Eina_Bool check_value = elm_check_state_get(m_edit_mode_select_all_check_button);
730         m_select_all_check_value = check_value;
731
732         if (check_value)
733                 elm_check_state_set(m_edit_mode_select_all_check_button, !check_value);
734 }
735
736 void Browser_History_Layout::__select_processing_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
737 {
738         BROWSER_LOGD("[%s]", __func__);
739         if (!data)
740                 return;
741
742         Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
743
744         evas_object_del(history_layout->m_processing_popup);
745
746         history_layout->m_processing_progress_bar = NULL;
747         history_layout->m_processed_it = NULL;
748
749         if (history_layout->m_processing_popup_timer) {
750                 ecore_timer_del(history_layout->m_processing_popup_timer);
751                 history_layout->m_processing_popup_timer = NULL;
752         }
753
754         Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
755         int check_count = 0;
756         while (it) {
757                 Browser_History_DB::history_item *item = NULL;
758                 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
759                 if (item) {
760                         if(item->is_delete && elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
761                                 check_count++;
762                 }
763                 it = elm_genlist_item_next_get(it);
764         }
765
766         history_layout->_delete_date_only_label_genlist_item();
767
768         if (check_count)
769                 elm_object_item_disabled_set(m_data_manager->get_bookmark_view()->m_bookmark_delete_controlbar_item, EINA_FALSE);
770         else
771                 elm_object_item_disabled_set(m_data_manager->get_bookmark_view()->m_bookmark_delete_controlbar_item, EINA_TRUE);
772 }
773
774 Eina_Bool Browser_History_Layout::__select_processing_popup_timer_cb(void *data)
775 {
776         if (!data)
777                 return ECORE_CALLBACK_CANCEL;
778
779         Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
780         Evas_Object* progress_bar = history_layout->m_processing_progress_bar;
781
782         Eina_Bool check_value = history_layout->m_select_all_check_value;
783
784         double value = elm_progressbar_value_get(progress_bar);
785         if (value >= 1.0) {
786                 __select_processing_popup_response_cb(history_layout, NULL, NULL);
787
788                 history_layout->m_processing_popup_timer = NULL;
789                 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, !check_value);
790                 history_layout->_show_selection_info();
791
792                 return ECORE_CALLBACK_CANCEL;
793         }
794
795         while (history_layout->m_processed_it) {
796                 Browser_History_DB::history_item *item = NULL;
797                 item = (Browser_History_DB::history_item *)elm_object_item_data_get(history_layout->m_processed_it);            
798                 if (item && (elm_genlist_item_select_mode_get(history_layout->m_processed_it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)) {
799                         item->is_delete = !check_value;
800                         elm_genlist_item_update(history_layout->m_processed_it);
801                         history_layout->m_processed_count++;
802                 }
803                 history_layout->m_processed_it = elm_genlist_item_next_get(history_layout->m_processed_it);
804
805                 if (history_layout->m_processed_count % 30 == 0)
806                         break;
807         }
808
809         elm_progressbar_value_set(history_layout->m_processing_progress_bar,
810                                 (float)((float)history_layout->m_processed_count / (float)(history_layout->m_history_list.size())));
811
812         char progress_text[20] = {0, };
813         snprintf(progress_text, sizeof(progress_text) - 1, "%d / %d",
814                         history_layout->m_processed_count, history_layout->m_history_list.size());
815
816         edje_object_part_text_set(elm_layout_edje_get(history_layout->m_processing_popup_layout),
817                                 "elm.text.right", progress_text);
818
819         return ECORE_CALLBACK_RENEW;
820 }
821
822 void Browser_History_Layout::__edit_mode_select_all_check_changed_cb(void *data,
823                                                         Evas_Object *obj, void *event_info)
824 {
825         BROWSER_LOGD("[%s]", __func__);
826         if (!data)
827                 return;
828
829         Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
830         Eina_Bool value = elm_check_state_get(obj);
831
832         if (history_layout->m_history_list.size() >= BROWSER_BOOKMARK_PROCESS_BLOCK_COUNT) {
833                 elm_check_state_set(obj, !value);
834                 history_layout->_show_select_processing_popup();
835         } else {
836                 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
837                 while (it) {
838                         Browser_History_DB::history_item *item = NULL;
839                         item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
840                         if (item) {                             
841                                 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
842                                         item->is_delete = value;
843                                         elm_genlist_item_update(it);
844                                 }
845                         }
846                         it = elm_genlist_item_next_get(it);
847                 }
848
849                 history_layout->_show_selection_info();
850         }
851 }
852
853 void Browser_History_Layout::__edit_mode_select_all_clicked_cb(void *data, Evas *evas,
854                                                                 Evas_Object *obj, void *event_info)
855 {       
856         if (!data)
857                 return;
858
859         Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
860
861         if (history_layout->m_history_list.size() >= BROWSER_BOOKMARK_PROCESS_BLOCK_COUNT) {
862                 history_layout->_show_select_processing_popup();
863         } else {
864                 Eina_Bool value = elm_check_state_get(history_layout->m_edit_mode_select_all_check_button);
865                 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, !value);
866
867                 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
868                 while (it) {
869                         Browser_History_DB::history_item *item = NULL;
870                         item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
871                         if (item) {
872                                 /* Ignore the date label. */
873                                 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
874                                         item->is_delete = !value;
875                                         elm_genlist_item_update(it);
876                                 }
877                         }
878                         it = elm_genlist_item_next_get(it);
879                 }
880
881                 history_layout->_show_selection_info();
882         }
883 }
884
885 void Browser_History_Layout::__history_item_clicked_cb(void *data, Evas_Object *obj, void *eventInfo)
886 {
887         BROWSER_LOGD("[%s]", __func__);
888         if (!data)
889                 return;
890
891         Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
892
893         if (history_layout->m_is_bookmark_on_off_icon_clicked) {
894                 history_layout->m_is_bookmark_on_off_icon_clicked = EINA_FALSE;
895                 Elm_Object_Item *selected_item = (Elm_Object_Item *)eventInfo;
896                 elm_genlist_item_selected_set(selected_item, EINA_FALSE);
897                 return;
898         }
899
900         Elm_Object_Item *seleted_item = elm_genlist_selected_item_get(obj);
901         Elm_Object_Item *index_item = elm_genlist_first_item_get(obj);
902         int index = 0;
903
904         if (!elm_genlist_decorate_mode_get(obj)) {
905                 /* calculate the index of the selected item */
906                 while (index_item != seleted_item) {
907                         /* Do not count date label item */
908                         if (elm_genlist_item_select_mode_get(index_item) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
909                                 index++;
910
911                         index_item = elm_genlist_item_next_get(index_item);
912                 }
913
914                 const char *selected_url = NULL;
915                 if (history_layout->m_searched_history_genlist == obj)
916                         selected_url = history_layout->m_searched_history_item_list[index]->url.c_str();
917                 else
918                         selected_url = history_layout->m_history_list[index]->url.c_str();
919
920                 m_data_manager->get_bookmark_view()->history_item_clicked(selected_url);
921         } else {
922                 Browser_History_DB::history_item *item = NULL;
923                 item = (Browser_History_DB::history_item *)elm_object_item_data_get(seleted_item);
924                 if (item && elm_genlist_item_select_mode_get(seleted_item) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
925                         item->is_delete = !(item->is_delete);
926                         elm_genlist_item_update(seleted_item);
927                 }
928                 elm_genlist_item_selected_set(seleted_item, EINA_FALSE);
929
930                 int selected_count = 0;
931                 int total_count = 0;
932                 Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
933                 while(it) {
934                         item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
935                         if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
936                                 if (item->is_delete)
937                                         selected_count++;
938                                 total_count++;
939                         }
940                         it = elm_genlist_item_next_get(it);                     
941                 }
942
943                 if (selected_count == total_count)
944                         elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, EINA_TRUE);
945                 else
946                         elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, EINA_FALSE);
947
948                 history_layout->_show_selection_info();
949         }
950 }
951
952 void Browser_History_Layout::_delete_selected_history(void)
953 {
954         BROWSER_LOGD("[%s]", __func__);
955
956         Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
957         int delete_item_count = 0;
958         Browser_History_DB::history_item *item = NULL;
959         while (it) {
960                 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
961                 if ((elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) && item->is_delete) {
962                         delete_item_count++;
963                 }
964                 it = elm_genlist_item_next_get(it);
965         }
966
967         if (delete_item_count >= BROWSER_BOOKMARK_PROCESS_BLOCK_COUNT) {
968                 _show_delete_processing_popup();
969         } else {
970                 Eina_List *delete_item_list = NULL;
971                 it = elm_genlist_first_item_get(m_history_genlist);
972                 int remain_count = 0;
973                 Browser_History_DB::history_item *item = NULL;
974
975                 while (it) {
976                         item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
977                         if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
978                                 if (item->is_delete)
979                                         delete_item_list = eina_list_append(delete_item_list, it);
980                                 else
981                                         remain_count++;
982                         }
983                         it = elm_genlist_item_next_get(it);
984                 }
985
986                 int count = eina_list_count(delete_item_list);
987                 for (int i = 0; i < count; i++) {
988                         it = (Elm_Object_Item *)eina_list_data_get(delete_item_list);
989                         item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
990                         /* Delete history item */
991                         Eina_Bool ret = m_data_manager->get_history_db()->delete_history(item->id);
992                         if (!ret)
993                                 BROWSER_LOGD("history [%s] delete failed", item->title.c_str());
994
995                         delete_item_list = eina_list_next(delete_item_list);
996
997                         for(int index = 0 ; index < m_history_list.size() ; index++) {
998                                 if (m_history_list[index]->id == item->id) {
999                                         delete m_history_list[index];
1000                                         m_history_list.erase(m_history_list.begin() + index);
1001                                 }
1002                         }
1003
1004                         elm_object_item_del(it);
1005                 }
1006                 eina_list_free(delete_item_list);
1007
1008                 elm_check_state_set(m_edit_mode_select_all_check_button, EINA_FALSE);
1009
1010                 _delete_date_only_label_genlist_item();
1011
1012                 if (remain_count == 0) {
1013                         elm_box_unpack_all(m_content_box);
1014                         elm_genlist_clear(m_history_genlist);
1015                         evas_object_hide(m_history_genlist);
1016
1017                         if (m_edit_mode_select_all_layout) {
1018                                 evas_object_del(m_edit_mode_select_all_layout);
1019                                 m_edit_mode_select_all_layout = NULL;
1020                         }
1021                         if (m_edit_mode_select_all_check_button) {
1022                                 evas_object_del(m_edit_mode_select_all_check_button);
1023                                 m_edit_mode_select_all_check_button = NULL;
1024                         }
1025
1026                         m_no_history_label = elm_label_add(m_searchbar_layout);
1027                         if (!m_no_history_label) {
1028                                 BROWSER_LOGE("elm_label_add failed");
1029                                 return;
1030                         }
1031
1032                         std::string text = std::string("<color='#646464'>") + std::string(BR_STRING_NO_HISTORY);
1033                         elm_object_text_set(m_no_history_label, text.c_str());
1034                         evas_object_show(m_no_history_label);
1035                         elm_box_pack_start(m_content_box, m_no_history_label);
1036
1037                         Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
1038                         if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_DEFAULT))
1039                                 BROWSER_LOGE("_set_controlbar_type failed");
1040
1041                         elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_TRUE);
1042                 }
1043
1044                 show_notify_popup(BR_STRING_DELETED, 3, EINA_TRUE);
1045         }
1046 }
1047
1048 void Browser_History_Layout::_reload_history_genlist(void)
1049 {
1050         Elm_Object_Item *it = NULL;
1051         while (it = elm_genlist_first_item_get(m_history_genlist))
1052                 elm_object_item_del(it);
1053
1054         for(int i = 0 ; i < m_history_list.size() ; i++ ) {
1055                 if (m_history_list[i])
1056                         delete m_history_list[i];
1057         }
1058         elm_box_unpack_all(m_content_box);
1059         m_history_list.clear(); 
1060
1061         for(int i = 0 ; i < m_history_date_label_list.size() ; i++ ) {
1062                 if (m_history_date_label_list[i])
1063                         free(m_history_date_label_list[i]);
1064         }
1065         m_history_date_label_list.clear();
1066
1067         Eina_Bool ret = m_data_manager->get_history_db()->get_history_list(m_history_list);
1068         if (!ret)
1069                 BROWSER_LOGE("get_history_list failed");
1070
1071         unsigned int history_count = m_history_list.size();
1072         BROWSER_LOGD("history_count=%d", history_count);
1073
1074         Date date;
1075         for(int i = 0 ; i < history_count; i++) {
1076                 sscanf(m_history_list[i]->date.c_str(), "%d-%d-%d", &date.year, &date.month, &date.day);
1077                 m_history_list[i]->user_data = (void *)this;
1078                 if (m_last_date != date) {
1079                         m_last_date = date;
1080                         char *labe_item = strdup(m_history_list[i]->date.c_str());
1081                         if (!labe_item) {
1082                                 BROWSER_LOGE("strdup failed");
1083                                 return;
1084                         }
1085                         m_history_date_label_list.push_back(labe_item);
1086                         it = elm_genlist_item_append(m_history_genlist, &m_history_group_title_class,
1087                                                         labe_item, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
1088
1089                         elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1090                 }
1091                 elm_genlist_item_append(m_history_genlist, &m_history_genlist_item_class, m_history_list[i], it,
1092                                         ELM_GENLIST_ITEM_NONE, __history_item_clicked_cb, this);
1093         }
1094
1095         if (m_no_history_label) {
1096                 evas_object_del(m_no_history_label);
1097                 m_no_history_label = NULL;
1098         }
1099
1100         if (m_edit_mode_select_all_check_button) {
1101                 evas_object_del(m_edit_mode_select_all_check_button);
1102                 m_edit_mode_select_all_check_button = NULL;
1103         }
1104
1105         if (m_edit_mode_select_all_layout) {
1106                 evas_object_del(m_edit_mode_select_all_layout);
1107                 m_edit_mode_select_all_layout = NULL;
1108         }
1109
1110         if (m_history_list.size() == 0) {
1111                 evas_object_hide(m_history_genlist);
1112
1113                 m_no_history_label = elm_label_add(m_searchbar_layout);
1114                 if (!m_no_history_label) {
1115                         BROWSER_LOGE("elm_label_add failed");
1116                         return;
1117                 }
1118
1119                 std::string text = std::string("<color='#646464'>") + std::string(BR_STRING_NO_HISTORY);
1120                 elm_object_text_set(m_no_history_label, text.c_str());
1121                 evas_object_show(m_no_history_label);
1122                 elm_box_pack_start(m_content_box, m_no_history_label);
1123
1124                 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
1125                 if (!bookmark_view->_set_controlbar_type(Browser_Bookmark_View::HISTORY_VIEW_DEFAULT))
1126                         BROWSER_LOGE("_set_controlbar_type failed");
1127                 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_TRUE);
1128         } else {
1129                 elm_box_pack_start(m_content_box, m_history_genlist);
1130                 evas_object_show(m_history_genlist);
1131
1132                 Browser_Bookmark_View *bookmark_view = m_data_manager->get_bookmark_view();
1133                 elm_object_item_disabled_set(bookmark_view->m_bookmark_edit_controlbar_item, EINA_FALSE);
1134         }
1135 }
1136
1137 Eina_Bool Browser_History_Layout::_create_main_layout(void)
1138 {
1139         BROWSER_LOGD("[%s]", __func__);
1140         elm_object_style_set(m_bg, "default");  
1141
1142         m_searchbar_layout = elm_layout_add(m_navi_bar);
1143         if (!m_searchbar_layout) {
1144                 BROWSER_LOGE("elm_layout_add failed");
1145                 return EINA_FALSE;
1146         }
1147
1148         _enable_searchbar_layout(EINA_TRUE);
1149
1150         evas_object_show(m_searchbar_layout);
1151
1152         m_content_box = elm_box_add(m_searchbar_layout);
1153         if (!m_content_box) {
1154                 BROWSER_LOGE("elm_box_add failed");
1155                 return EINA_FALSE;
1156         }
1157
1158         m_history_genlist = _create_history_genlist();
1159         if (!m_history_genlist) {
1160                 BROWSER_LOGE("_create_history_genlist failed");
1161                 return EINA_FALSE;
1162         }
1163
1164         m_history_genlist_item_class.decorate_item_style = "mode/slide3";
1165         m_history_genlist_item_class.item_style = "2text.2icon.4";
1166         m_history_genlist_item_class.decorate_all_item_style = "edit_default";
1167         m_history_genlist_item_class.func.text_get = __genlist_label_get_cb;
1168         m_history_genlist_item_class.func.content_get = __genlist_icon_get_cb;
1169         m_history_genlist_item_class.func.state_get = NULL;
1170         m_history_genlist_item_class.func.del = NULL;
1171
1172         m_history_group_title_class.item_style = "grouptitle";
1173         m_history_group_title_class.func.text_get = __genlist_date_label_get_cb;
1174         m_history_group_title_class.func.content_get = NULL;
1175         m_history_group_title_class.func.state_get = NULL;
1176         m_history_group_title_class.func.del = NULL;
1177
1178         _reload_history_genlist();
1179
1180         evas_object_show(m_content_box);
1181         elm_object_part_content_set(m_searchbar_layout, "elm.swallow.content", m_content_box);
1182
1183         return EINA_TRUE;
1184 }
1185
1186 Evas_Object *Browser_History_Layout::_show_delete_confirm_popup(void)
1187 {
1188         BROWSER_LOGD("[%s]", __func__);
1189
1190         m_delete_confirm_popup = elm_popup_add(m_navi_bar);
1191         if (!m_delete_confirm_popup) {
1192                 BROWSER_LOGE("elm_popup_add failed");
1193                 return NULL;
1194         }
1195
1196         evas_object_size_hint_weight_set(m_delete_confirm_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1197         elm_object_text_set(m_delete_confirm_popup, BR_STRING_DELETE_Q);
1198
1199         Evas_Object *ok_button = elm_button_add(m_delete_confirm_popup);
1200         elm_object_text_set(ok_button, BR_STRING_YES);
1201         elm_object_part_content_set(m_delete_confirm_popup, "button1", ok_button);
1202
1203         Evas_Object *cancel_button = elm_button_add(m_delete_confirm_popup);
1204         elm_object_text_set(cancel_button, BR_STRING_NO);
1205         elm_object_part_content_set(m_delete_confirm_popup, "button2", cancel_button);
1206         evas_object_smart_callback_add(cancel_button, "clicked", __cancel_confirm_response_by_slide_button_cb,
1207                                                                                 m_delete_confirm_popup);
1208
1209         evas_object_show(m_delete_confirm_popup);
1210
1211         return ok_button;
1212 }
1213
1214 #if defined(GENLIST_SWEEP)
1215 void Browser_History_Layout::__sweep_right_genlist_cb(void *data, Evas_Object *obj, void *event_info)
1216 {
1217         BROWSER_LOGD("[%s]", __func__);
1218         if (!data || elm_genlist_decorate_mode_get(obj))
1219                 return;
1220         else {
1221                 elm_genlist_item_decorate_mode_set((Elm_Object_Item *)event_info, "slide", EINA_TRUE);
1222                 elm_genlist_item_select_mode_set((Elm_Object_Item *)event_info, ELM_OBJECT_SELECT_MODE_NONE);
1223         }
1224
1225         Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
1226         if (history_layout->m_current_sweep_item)
1227                 elm_genlist_item_select_mode_set(history_layout->m_current_sweep_item, ELM_OBJECT_SELECT_MODE_DEFAULT);
1228         history_layout->m_current_sweep_item = (Elm_Object_Item *)event_info;
1229 }
1230
1231 void Browser_History_Layout::__sweep_cancel_genlist_cb(void *data,
1232                                                 Evas_Object *obj, void *event_info)
1233 {
1234         BROWSER_LOGD("[%s]", __func__);
1235
1236         if (!data)
1237                 return;
1238
1239         Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
1240         Elm_Object_Item *it = (Elm_Object_Item*)elm_genlist_decorated_item_get(obj);
1241         if (it) {
1242                 elm_genlist_item_decorate_mode_set(it, "slide", EINA_FALSE);
1243                 elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DEFAULT);
1244
1245                 if (it == history_layout->m_current_sweep_item)
1246                         history_layout->m_current_sweep_item = NULL;
1247         }
1248 }
1249
1250 void Browser_History_Layout::__sweep_left_genlist_cb(void *data, Evas_Object *obj, void *event_info)
1251 {
1252         BROWSER_LOGD("[%s]", __func__);
1253         if (!data || elm_genlist_decorate_mode_get(obj))
1254                 return;
1255         else {
1256                 elm_genlist_item_decorate_mode_set((Elm_Object_Item *)event_info, "slide", EINA_FALSE);
1257                 elm_genlist_item_select_mode_set((Elm_Object_Item *)event_info, ELM_OBJECT_SELECT_MODE_DEFAULT);
1258         }
1259
1260         Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
1261         history_layout->m_current_sweep_item = NULL;
1262 }
1263 #endif
1264
1265 char *Browser_History_Layout::__genlist_label_get_cb(void *data, Evas_Object *obj, const char *part)
1266 {
1267         if (!data)
1268                 return NULL;
1269
1270         Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1271         if (!item)
1272                 return NULL;
1273
1274         char *mark_up = NULL;
1275
1276         if (!strncmp(part, "elm.text.1", strlen("elm.text.1"))
1277                 || !strncmp(part, "elm.base.text", strlen("elm.base.text"))
1278                 || !strncmp(part, "elm.slide.text.1", strlen("elm.slide.text.1")))
1279         {
1280                 mark_up = elm_entry_utf8_to_markup(item->title.c_str());
1281                 return mark_up;
1282         } else if (!strncmp(part, "elm.text.2", strlen("elm.text.2"))
1283                 || !strncmp(part, "elm.slide.text.2", strlen("elm.slide.text.2"))) {
1284                 mark_up = elm_entry_utf8_to_markup(item->url.c_str());
1285                 return mark_up;
1286         }
1287
1288         return NULL;
1289 }
1290
1291 char *Browser_History_Layout::__genlist_date_label_get_cb(void *data, Evas_Object *obj, const char *part)
1292 {
1293         if (!data)
1294                 return NULL;
1295
1296         char *date_label = (char *)data;
1297
1298         if (!strncmp(part, "elm.text", strlen("elm.text"))) {
1299                 Date date;
1300                 char buffer[BROWSER_MAX_DATE_LEN] = {0, };
1301
1302                 sscanf(date_label, "%d-%d-%d",
1303                         &date.year, &date.month, &date.day);
1304 //              BROWSER_LOGD("%d %d %d\n", date.day, date.month, date.year);
1305                 time_t raw_time;
1306                 struct tm *time_info;
1307                 time(&raw_time);
1308                 time_info = localtime(&raw_time);
1309                 int day_gap = -1;
1310 //              BROWSER_LOGD("\ncurrent time : %d %d %d\n", time_info->tm_mday, (time_info->tm_mon+1), (time_info->tm_year+1900));
1311                 if (time_info->tm_year == date.year -1900 && time_info->tm_mon == date.month - 1)
1312                         day_gap = time_info->tm_mday - date.day;
1313                 else {
1314                         time_info->tm_year = date.year - 1900;
1315                         time_info->tm_mon = date.month - 1;
1316                 }
1317                 time_info->tm_mday = date.day;
1318                 mktime(time_info);
1319
1320                 if (day_gap == 0)
1321                         strftime (buffer, BROWSER_MAX_DATE_LEN, "Today (%a, %b %d %Y)", time_info);
1322                 else if (day_gap == 1)
1323                         strftime (buffer, 40, "Yesterday (%a, %b %d %Y)", time_info);
1324                 else
1325                         strftime (buffer, 40, "%a, %b %d %Y", time_info);
1326                 return strdup(buffer);
1327         }
1328         return NULL;
1329 }
1330
1331 void Browser_History_Layout::__slide_add_to_bookmark_button_clicked_cb(void *data, Evas_Object *obj,
1332                                                                                 void *event_info)
1333 {
1334         BROWSER_LOGD("[%s]", __func__);
1335         if (!data)
1336                 return;
1337
1338         Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1339         Browser_History_Layout *history_layout = (Browser_History_Layout *)item->user_data;
1340
1341         /* If add to bookmark is excuted in searched list, remove the searched list. */
1342         Evas_Object *searchbar = NULL;
1343         searchbar = edje_object_part_external_object_get(elm_layout_edje_get(history_layout->m_searchbar_layout),
1344                                                                                 "searchbar");
1345         br_elm_searchbar_text_set(searchbar, "");
1346
1347         if (!m_data_manager->create_add_to_bookmark_view(item->title, item->url)) {
1348                 BROWSER_LOGE("create_add_to_bookmark_view failed");
1349                 return;
1350         }
1351
1352         if (!m_data_manager->get_add_to_bookmark_view()->init()) {
1353                 BROWSER_LOGE("get_add_to_bookmark_view()->init() failed");
1354                 m_data_manager->destroy_add_to_bookmark_view();
1355                 return;
1356         }
1357 }
1358
1359 void Browser_History_Layout::__slide_share_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
1360 {
1361         BROWSER_LOGD("[%s]", __func__);
1362         if (!data)
1363                 return;
1364
1365         Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1366         Browser_History_Layout *history_layout = (Browser_History_Layout *)item->user_data;
1367         if (!history_layout->_show_share_popup(item->url.c_str()))
1368                 BROWSER_LOGE("_show_share_popup failed");
1369 }
1370
1371 void Browser_History_Layout::_delete_history_item_by_slide_button(Browser_History_DB::history_item *item)
1372 {
1373         BROWSER_LOGD("[%s]", __func__);
1374         Browser_History_Layout *history_layout = (Browser_History_Layout *)(item->user_data);
1375
1376         int ret = EINA_TRUE;
1377         ret = m_data_manager->get_history_db()->delete_history(item->id);
1378         if (!ret) {
1379                 BROWSER_LOGE("m_data_manager->get_history_db()->delete_history failed");
1380                 return;
1381         }
1382
1383         elm_object_item_del(history_layout->m_current_sweep_item);
1384
1385         /* If the item is deleted in searched list, then delete it from original history genlist also. */
1386         Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
1387         while (it) {
1388                 Browser_History_DB::history_item *item_data = NULL;
1389                 item_data = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
1390                 if (item_data && (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)) {
1391                         if (item_data->id == item->id) {
1392                                 elm_object_item_del(it);
1393                                 break;
1394                         }
1395                 }
1396                 it = elm_genlist_item_next_get(it);
1397         }
1398
1399         for(int i = 0 ; i < history_layout->m_history_list.size() ; i++) {
1400                 if (history_layout->m_history_list[i]->id == item->id) {
1401                         delete history_layout->m_history_list[i];
1402                         history_layout->m_history_list.erase(history_layout->m_history_list.begin() + i);
1403                         break;
1404                 }
1405         }
1406
1407         if (history_layout->m_history_list.size() == 0) {
1408                 history_layout->_reload_history_genlist();
1409         }
1410
1411         history_layout->_delete_date_only_label_genlist_item();
1412
1413         show_notify_popup(BR_STRING_DELETED, 3, EINA_TRUE);
1414 }
1415
1416 void Browser_History_Layout::__delete_confirm_response_by_edit_mode_cb(void *data, Evas_Object *obj,
1417                                                                 void *event_info)
1418 {
1419         BROWSER_LOGD("event_info = %d", (int)event_info);
1420
1421         if (!data)
1422                 return;
1423
1424         Browser_History_Layout *history_layout = (Browser_History_Layout *)data;
1425
1426         if (history_layout->m_delete_confirm_popup) {
1427                 evas_object_del(history_layout->m_delete_confirm_popup);
1428                 history_layout->m_delete_confirm_popup = NULL;
1429         }
1430
1431         history_layout->_delete_selected_history();
1432
1433         if (history_layout->m_history_list.size() < BROWSER_BOOKMARK_PROCESS_BLOCK_COUNT) {
1434                 history_layout->_set_edit_mode(EINA_FALSE);
1435         }
1436 }
1437
1438 void Browser_History_Layout::__delete_confirm_response_by_slide_button_cb(void *data, Evas_Object *obj,
1439                                                                 void *event_info)
1440 {
1441         BROWSER_LOGD("event_info = %d", (int)event_info);
1442
1443         if (!data)
1444                 return;
1445
1446         Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1447         Browser_History_Layout *history_layout = (Browser_History_Layout *)(item->user_data);
1448         if (history_layout->m_delete_confirm_popup) {
1449                 evas_object_del(history_layout->m_delete_confirm_popup);
1450                 history_layout->m_delete_confirm_popup = NULL;
1451         }
1452
1453         history_layout->_delete_history_item_by_slide_button(item);
1454 }
1455
1456 void Browser_History_Layout::__cancel_confirm_response_by_slide_button_cb(void *data, Evas_Object *obj,
1457                                                                 void *event_info)
1458 {
1459         BROWSER_LOGD("event_info = %d", (int)event_info);
1460
1461         if (!data)
1462                 return;
1463
1464         Evas_Object *popup = (Evas_Object *)data;
1465         evas_object_del(popup);
1466 }
1467
1468 void Browser_History_Layout::_delete_date_only_label_genlist_item(void)
1469 {
1470         BROWSER_LOGD("[%s]", __func__);
1471
1472         Elm_Object_Item *it = elm_genlist_first_item_get(m_history_genlist);
1473         /* Remove date only label item */
1474         while (it) {
1475                 if (elm_genlist_item_select_mode_get(it) == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
1476                         Elm_Object_Item *tmp_it = elm_genlist_item_next_get(it);
1477                         if (!tmp_it || elm_genlist_item_select_mode_get(tmp_it) == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
1478                                 tmp_it = it;
1479                                 it = elm_genlist_item_next_get(it);
1480                                 elm_object_item_del(tmp_it);
1481                                 continue;
1482                         }
1483                 }
1484                 it = elm_genlist_item_next_get(it);
1485         }
1486 }
1487
1488 void Browser_History_Layout::__slide_delete_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
1489 {
1490         BROWSER_LOGD("[%s]", __func__);
1491         if (!data)
1492                 return;
1493
1494         Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1495         Browser_History_Layout *history_layout = (Browser_History_Layout *)item->user_data;
1496
1497         Evas_Object *ok_button = history_layout->_show_delete_confirm_popup();
1498         if (ok_button)
1499                 evas_object_smart_callback_add(ok_button, "clicked",
1500                         __delete_confirm_response_by_slide_button_cb, item);
1501 }
1502
1503 void Browser_History_Layout::__bookmark_on_off_icon_clicked_cb(void* data, Evas* evas, Evas_Object* obj, void* ev)
1504 {
1505         BROWSER_LOGD("[%s]", __func__);
1506         Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1507         Browser_History_Layout *history_layout = (Browser_History_Layout *)item->user_data;
1508
1509         history_layout->m_is_bookmark_on_off_icon_clicked = EINA_TRUE;
1510
1511         int bookmark_id = -1;
1512         if (m_data_manager->get_history_db()->is_in_bookmark(item->url.c_str(), &bookmark_id)) {
1513                 if (!elm_icon_file_set(obj, BROWSER_IMAGE_DIR"/I01_icon_bookmark_off.png", NULL)) {
1514                         BROWSER_LOGE("elm_icon_file_set is failed.\n");
1515                 }
1516                 m_data_manager->get_bookmark_view()->delete_bookmark_item(bookmark_id);
1517         } else {
1518                 if (!elm_icon_file_set(obj, BROWSER_IMAGE_DIR"/I01_icon_bookmark_on.png", NULL)) {
1519                         BROWSER_LOGE("elm_icon_file_set is failed.\n");
1520                 }
1521                 m_data_manager->get_bookmark_view()->append_bookmark_item(item->title.c_str(), item->url.c_str());
1522         }
1523 }
1524
1525 Evas_Object *Browser_History_Layout::__genlist_icon_get_cb(void *data, Evas_Object *obj, const char *part)
1526 {
1527         if (!data || !part)
1528                 return NULL;
1529
1530         Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1531         Browser_History_Layout *history_layout = (Browser_History_Layout *)item->user_data;
1532         if (!history_layout)
1533                 return NULL;
1534
1535         if (!strncmp(part, "elm.icon.1", strlen("elm.icon.1"))) {
1536                 Evas_Object *favicon = NULL;
1537                 favicon = m_data_manager->get_browser_view()->get_favicon(item->url.c_str());
1538                 if (favicon)
1539                         return favicon;
1540                 else {
1541                         Evas_Object *default_favicon = elm_icon_add(obj);
1542                         if (!default_favicon) {
1543                                 BROWSER_LOGE("elm_icon_add is failed");
1544                                 return NULL;
1545                         }
1546                         elm_icon_file_set(default_favicon, BROWSER_IMAGE_DIR"/faviconDefault.png", NULL);
1547                         evas_object_size_hint_aspect_set(default_favicon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1548                         return default_favicon;
1549                 }
1550         } else if (!strncmp(part, "elm.icon.2", strlen("elm.icon.2"))) {
1551                 Evas_Object *bookmark_icon = elm_icon_add(obj);
1552                 if (m_data_manager->get_history_db()->is_in_bookmark(item->url.c_str(), NULL)) {
1553                         if (!elm_icon_file_set(bookmark_icon, BROWSER_IMAGE_DIR"/I01_icon_bookmark_on.png", NULL)) {
1554                                 BROWSER_LOGE("elm_icon_file_set is failed.\n");
1555                                 return NULL;
1556                         }
1557                 } else {
1558                         if (!elm_icon_file_set(bookmark_icon, BROWSER_IMAGE_DIR"/I01_icon_bookmark_off.png", NULL)) {
1559                                 BROWSER_LOGE("elm_icon_file_set is failed.\n");
1560                                 return NULL;
1561                         }
1562                 }
1563                 evas_object_size_hint_aspect_set(bookmark_icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1564                 evas_object_propagate_events_set(bookmark_icon, EINA_FALSE);
1565                 evas_object_repeat_events_set(bookmark_icon, EINA_FALSE);
1566
1567                 evas_object_event_callback_add(bookmark_icon, EVAS_CALLBACK_MOUSE_DOWN,
1568                                                 __bookmark_on_off_icon_clicked_cb, item);
1569
1570                 return bookmark_icon;
1571         } else if (!strncmp(part, "elm.edit.icon.1", strlen("elm.edit.icon.1"))) {
1572                 if (elm_genlist_decorate_mode_get(obj)) {
1573                         Evas_Object *check_button = elm_check_add(obj);
1574                         if (!check_button) {
1575                                 BROWSER_LOGE("elm_check_add is failed");
1576                                 return NULL;
1577                         }
1578                         elm_check_state_pointer_set(check_button, &(item->is_delete));
1579                         elm_check_state_set(check_button, item->is_delete);
1580                         evas_object_smart_callback_add(check_button, "changed", __edit_mode_item_check_changed_cb, item);
1581                         return check_button;
1582                 }
1583         } else if (!strncmp(part, "elm.slide.swallow.1", strlen("elm.slide.swallow.1"))) {
1584                 Evas_Object *button = elm_button_add(obj);
1585                 if (!button) {
1586                         LOGD("elm_button_add() is failed.");
1587                         return NULL;
1588                 }
1589
1590                 elm_object_style_set(button, "sweep/multiline");
1591                 elm_object_text_set(button, BR_STRING_SHARE);
1592                 evas_object_smart_callback_add(button, "clicked", __slide_share_button_clicked_cb, item);
1593                 return button;
1594         } else if (!strncmp(part, "elm.slide.swallow.2", strlen("elm.slide.swallow.2"))) {
1595                 Evas_Object *button = elm_button_add(obj);
1596                 if (!button) {
1597                         LOGD("elm_button_add() is failed.");
1598                         return NULL;
1599                 }
1600                 elm_object_style_set(button, "sweep/multiline");
1601                 elm_object_text_set(button, BR_STRING_ADD_TO_BOOKMARKS);
1602                 evas_object_smart_callback_add(button, "clicked", __slide_add_to_bookmark_button_clicked_cb, item);
1603                 return button;  
1604         } else if (!strncmp(part, "elm.slide.swallow.3", strlen("elm.slide.swallow.3"))) {
1605                 Evas_Object *button = elm_button_add(obj);
1606                 if (!button) {
1607                         LOGD("elm_button_add() is failed.");
1608                         return NULL;
1609                 }
1610                 elm_object_style_set(button, "sweep/multiline");
1611                 elm_object_text_set(button, BR_STRING_DELETE);
1612                 evas_object_smart_callback_add(button, "clicked", __slide_delete_button_clicked_cb, item);
1613                 return button;
1614         }
1615
1616         return NULL;
1617 }
1618
1619 void Browser_History_Layout::__edit_mode_item_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
1620 {
1621         BROWSER_LOGD("[%s]", __func__);
1622         if (!data)
1623                 return;
1624         Browser_History_DB::history_item *item = (Browser_History_DB::history_item *)data;
1625         Browser_History_Layout *history_layout = (Browser_History_Layout *)(item->user_data);
1626         int selected_count = 0;
1627         int total_count = 0;
1628         Elm_Object_Item *it = elm_genlist_first_item_get(history_layout->m_history_genlist);
1629         while(it) {
1630                 Browser_History_DB::history_item *item = NULL;
1631                 item = (Browser_History_DB::history_item *)elm_object_item_data_get(it);
1632
1633                 /* Ignore the date label. */
1634                 if (elm_genlist_item_select_mode_get(it) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
1635                         total_count++;
1636                         if (item->is_delete)
1637                                 selected_count++;
1638                 }
1639                 it = elm_genlist_item_next_get(it);
1640         }
1641
1642         if (total_count == selected_count)
1643                 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, EINA_TRUE);
1644         else
1645                 elm_check_state_set(history_layout->m_edit_mode_select_all_check_button, EINA_FALSE);
1646
1647         history_layout->_show_selection_info();
1648 }
1649
1650 Evas_Object *Browser_History_Layout::_create_history_genlist(void)
1651 {
1652         BROWSER_LOGD("[%s]", __func__);
1653         Evas_Object *genlist = elm_genlist_add(m_searchbar_layout);
1654         if (genlist) {
1655                 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1656                 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
1657
1658 #if defined(GENLIST_SWEEP)
1659                 evas_object_smart_callback_add(genlist, "drag,start,right", __sweep_right_genlist_cb, this);
1660                 evas_object_smart_callback_add(genlist, "drag,start,left", __sweep_left_genlist_cb, this);
1661                 evas_object_smart_callback_add(genlist, "drag,start,up", __sweep_cancel_genlist_cb, this);
1662                 evas_object_smart_callback_add(genlist, "drag,start,down", __sweep_cancel_genlist_cb, this);
1663 #endif
1664         }
1665
1666         return genlist;
1667 }
1668