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