Changeset 172923 in webkit
- Timestamp:
- Aug 25, 2014 6:40:17 AM (10 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r172905 r172923 1 2014-08-25 Tanay C <tanay.c@samsung.com> 2 3 [EFL][WK2] Minibrowser : Enhance application to be able to support history list navigation 4 https://bugs.webkit.org/show_bug.cgi?id=135795 5 6 Reviewed by Gyuyoung Kim. 7 8 * MiniBrowser/efl/main.c: Adding functionality for long press history list navigation 9 (history_list_hide): Hiding and dereferencing the history list and items 10 (on_key_down): 11 (on_mouse_down): 12 (on_back_button_clicked): Early return for longpress 13 (on_forward_button_clicked): Early return for longpress 14 (list_item_label_get): Populate item labels 15 (on_list_item_select): Navigates on selection from history list 16 (navigation_button_longpress_process): Populates the history list and displays it 17 (on_forward_button_longpress): 18 (on_back_button_longpress): 19 (window_create): Add the widget for history list 20 1 21 2014-08-25 Carlos Alberto Lopez Perez <clopez@igalia.com> 2 22 -
trunk/Tools/MiniBrowser/efl/main.c
r172840 r172923 36 36 static const int DEFAULT_SEARCH_FLAGS = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE | EWK_FIND_OPTIONS_WRAP_AROUND; 37 37 static const double TOOLTIP_DELAY_SECONDS = 1.0; 38 static const double LONGPRESS_INTERVAL_SECONDS = 1.5; 39 static const double LIST_ITEM_HEIGHT = 24.35; 38 40 39 41 #define info(format, args...) \ … … 57 59 static Eina_Bool fixed_layout_enabled = EINA_FALSE; 58 60 static Eina_Bool separated_process_enabled = EINA_FALSE; 61 static Eina_Bool longpress_enabled = EINA_FALSE; 59 62 static int window_width = 800; 60 63 static int window_height = 600; … … 114 117 Evas_Object *close_button; 115 118 } search; 119 struct { 120 Evas_Object *history_box; 121 Evas_Object *history_list; 122 Eina_List *history_list_items; 123 } history; 116 124 int current_zoom_level; 117 125 Tooltip_Information tooltip; … … 399 407 } 400 408 409 static void 410 history_list_hide(Browser_Window *window) 411 { 412 /* Hide history list */ 413 evas_object_hide(window->history.history_box); 414 evas_object_hide(window->history.history_list); 415 416 /* Dereference the list items and clear the history list */ 417 void *data; 418 EINA_LIST_FREE(window->history.history_list_items, data) { 419 ewk_object_unref(data); 420 } 421 422 elm_genlist_clear(window->history.history_list); 423 424 /* Give focus back to the view */ 425 elm_object_focus_set(window->history.history_box, EINA_FALSE); 426 elm_object_focus_set(window->history.history_list, EINA_FALSE); 427 evas_object_focus_set(window->ewk_view, EINA_TRUE); 428 429 /* Reset flags */ 430 longpress_enabled = EINA_FALSE; 431 } 432 401 433 static void save_page_contents_callback(Ewk_Page_Contents_Type type, const char *data, void *user_data) 402 434 { … … 506 538 if (evas_object_visible_get(window->search.search_bar)) 507 539 search_box_hide(window); 540 else if (evas_object_visible_get(window->history.history_box)) 541 history_list_hide(window); 508 542 else if (elm_win_fullscreen_get(window->elm_window)) 509 543 ewk_view_fullscreen_exit(ewk_view); … … 564 598 elm_entry_select_none(window->url_bar); 565 599 600 if (longpress_enabled) 601 history_list_hide(window); 566 602 if (ev->button == 1) 567 603 view_focus_set(window, EINA_TRUE); … … 1013 1049 on_back_button_clicked(void *user_data, Evas_Object *back_button, void *event_info) 1014 1050 { 1051 if (longpress_enabled) 1052 return; 1053 1015 1054 Browser_Window *window = (Browser_Window *)user_data; 1016 1055 … … 1023 1062 on_forward_button_clicked(void *user_data, Evas_Object *forward_button, void *event_info) 1024 1063 { 1064 if (longpress_enabled) 1065 return; 1066 1025 1067 Browser_Window *window = (Browser_Window *)user_data; 1026 1068 … … 1081 1123 info("Stop was Pressed. Aborting load..."); 1082 1124 ewk_view_stop(window->ewk_view); 1125 } 1126 1127 static char * 1128 list_item_label_get(void *data, Evas_Object *obj, const char *part) 1129 { 1130 int len = strlen((char *)data); 1131 char *buf = (char *)malloc(sizeof(char) * (len + 1)); 1132 snprintf(buf, len + 1, "%s", (char *)data); 1133 return buf; 1134 } 1135 1136 static void 1137 on_list_item_select(void *user_data, Evas_Object *obj, void *event_info) 1138 { 1139 Browser_Window *window = evas_object_data_get(obj, "Browser_Window"); 1140 ewk_view_navigate_to(window->ewk_view, user_data); 1141 history_list_hide(window); 1142 evas_object_data_del(obj, "Browser_Window"); 1143 } 1144 1145 static void 1146 navigation_button_longpress_process(void *user_data, Eina_Bool forward_navigation_enabled) 1147 { 1148 if (longpress_enabled) 1149 return; 1150 1151 longpress_enabled = EINA_TRUE; 1152 Browser_Window *window = (Browser_Window *)user_data; 1153 1154 Ewk_Back_Forward_List *list = ewk_view_back_forward_list_get(window->ewk_view); 1155 const Eina_List *l; 1156 void *data; 1157 static Elm_Genlist_Item_Class *list_item = NULL; 1158 const char *title = NULL; 1159 int item_count; 1160 int x; 1161 int y; 1162 int width; 1163 int height; 1164 size_t index; 1165 1166 evas_object_data_set(window->history.history_list, "Browser_Window", window); 1167 1168 if (forward_navigation_enabled) 1169 window->history.history_list_items = ewk_back_forward_list_forward_items_copy(list); 1170 else 1171 window->history.history_list_items = ewk_back_forward_list_back_items_copy(list); 1172 1173 if (!list_item) { 1174 list_item = elm_genlist_item_class_new(); 1175 list_item->item_style = "default"; 1176 list_item->func.text_get = list_item_label_get; 1177 list_item->func.content_get = NULL; 1178 list_item->func.state_get = NULL; 1179 list_item->func.del = NULL; 1180 } 1181 1182 item_count = eina_list_count(window->history.history_list_items); 1183 info("navigation_button_longpress_process : Item count = %d forward_navigation_enabled = %d", item_count, forward_navigation_enabled); 1184 1185 EINA_LIST_FOREACH(window->history.history_list_items, l, data) { 1186 title = ewk_back_forward_list_item_title_get(data); 1187 info(" title = %s", title); 1188 elm_genlist_item_append(window->history.history_list, list_item, (void *)(title), NULL, ELM_GENLIST_ITEM_NONE, on_list_item_select, data); 1189 } 1190 1191 if (item_count > 0) { 1192 evas_object_geometry_get(window->elm_window, &x, &y, &width, &height); 1193 elm_list_go(window->history.history_list); 1194 evas_object_resize(window->history.history_box , width / 3 , LIST_ITEM_HEIGHT * item_count); 1195 1196 if (forward_navigation_enabled) { 1197 evas_object_move(window->history.history_box , x + TOOL_BAR_BUTTON_SIZE + 1, y + TOOL_BAR_BUTTON_SIZE); 1198 evas_object_move(window->history.history_list , x + TOOL_BAR_BUTTON_SIZE + 1, y + TOOL_BAR_BUTTON_SIZE); 1199 } else { 1200 evas_object_move(window->history.history_box , x, y + TOOL_BAR_BUTTON_SIZE); 1201 evas_object_move(window->history.history_list , x, y + TOOL_BAR_BUTTON_SIZE); 1202 } 1203 1204 elm_genlist_mode_set(window->history.history_list, ELM_LIST_COMPRESS); 1205 evas_object_show(window->history.history_box); 1206 evas_object_show(window->history.history_list); 1207 evas_object_focus_set(window->ewk_view, EINA_FALSE); 1208 elm_object_focus_set(window->history.history_list, EINA_TRUE); 1209 } else 1210 longpress_enabled = EINA_FALSE; 1211 } 1212 1213 static void 1214 on_forward_button_longpress(void *user_data, Evas_Object *forward_button, void *event_info) 1215 { 1216 Browser_Window *window = (Browser_Window *)user_data; 1217 1218 navigation_button_longpress_process(user_data, EINA_TRUE); 1219 elm_object_disabled_set(forward_button, !ewk_view_back_possible(window->ewk_view)); 1220 } 1221 1222 static void 1223 on_back_button_longpress(void *user_data, Evas_Object *back_button, void *event_info) 1224 { 1225 Browser_Window *window = (Browser_Window *)user_data; 1226 1227 navigation_button_longpress_process(user_data, EINA_FALSE); 1228 elm_object_disabled_set(back_button, !ewk_view_back_possible(window->ewk_view)); 1083 1229 } 1084 1230 … … 1814 1960 window->back_button = create_toolbar_button(window->elm_window, "arrow_left"); 1815 1961 evas_object_smart_callback_add(window->back_button, "clicked", on_back_button_clicked, window); 1962 evas_object_smart_callback_add(window->back_button, "repeated", on_back_button_longpress, window); 1816 1963 elm_object_disabled_set(window->back_button, EINA_TRUE); 1817 1964 evas_object_size_hint_weight_set(window->back_button, 0.0, EVAS_HINT_EXPAND); … … 1823 1970 window->forward_button = create_toolbar_button(window->elm_window, "arrow_right"); 1824 1971 evas_object_smart_callback_add(window->forward_button, "clicked", on_forward_button_clicked, window); 1972 evas_object_smart_callback_add(window->forward_button, "repeated", on_forward_button_longpress, window); 1825 1973 elm_object_disabled_set(window->forward_button, EINA_TRUE); 1826 1974 evas_object_size_hint_weight_set(window->forward_button, 0.0, EVAS_HINT_EXPAND); … … 1924 2072 elm_box_pack_end(window->search.search_bar, window->search.close_button); 1925 2073 2074 /* Create history box */ 2075 window->history.history_box = elm_box_add(window->elm_window); 2076 evas_object_size_hint_aspect_set(window->history.history_box, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); 2077 evas_object_size_hint_weight_set(window->history.history_box, EVAS_HINT_EXPAND , EVAS_HINT_EXPAND); 2078 2079 /* Create history list */ 2080 window->history.history_list = elm_genlist_add(window->elm_window); 2081 evas_object_size_hint_weight_set(window->history.history_list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 2082 evas_object_size_hint_align_set(window->history.history_list, EVAS_HINT_FILL, EVAS_HINT_FILL); 2083 elm_win_resize_object_add(window->history.history_list, window->history.history_box); 2084 elm_box_pack_end(window->history.history_box, window->history.history_list); 2085 1926 2086 /* Create ewk_view */ 1927 2087 Ewk_View_Smart_Class *ewkViewClass = miniBrowserViewSmartClass(); … … 2016 2176 evas_object_event_callback_add(window->ewk_view, EVAS_CALLBACK_MOUSE_MOVE, on_mouse_move, window); 2017 2177 evas_object_event_callback_add(window->elm_window, EVAS_CALLBACK_RESIZE, on_window_resize, window); 2178 2179 elm_button_autorepeat_set(window->back_button, EINA_TRUE); 2180 elm_button_autorepeat_set(window->forward_button, EINA_TRUE); 2181 elm_button_autorepeat_initial_timeout_set(window->back_button, LONGPRESS_INTERVAL_SECONDS); 2182 elm_button_autorepeat_initial_timeout_set(window->forward_button, LONGPRESS_INTERVAL_SECONDS); 2018 2183 2019 2184 return window;
Note: See TracChangeset
for help on using the changeset viewer.