Changeset 172923 in webkit


Ignore:
Timestamp:
Aug 25, 2014 6:40:17 AM (10 years ago)
Author:
commit-queue@webkit.org
Message:

[EFL][WK2] Minibrowser : Enhance application to be able to support history list navigation
https://bugs.webkit.org/show_bug.cgi?id=135795

Patch by Tanay C <tanay.c@samsung.com> on 2014-08-25
Reviewed by Gyuyoung Kim.

  • MiniBrowser/efl/main.c: Adding functionality for long press history list navigation

(history_list_hide): Hiding and dereferencing the history list and items
(on_key_down):
(on_mouse_down):
(on_back_button_clicked): Early return for longpress
(on_forward_button_clicked): Early return for longpress
(list_item_label_get): Populate item labels
(on_list_item_select): Navigates on selection from history list
(navigation_button_longpress_process): Populates the history list and displays it
(on_forward_button_longpress):
(on_back_button_longpress):
(window_create): Add the widget for history list

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r172905 r172923  
     12014-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
    1212014-08-25  Carlos Alberto Lopez Perez  <clopez@igalia.com>
    222
  • trunk/Tools/MiniBrowser/efl/main.c

    r172840 r172923  
    3636static const int DEFAULT_SEARCH_FLAGS = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE | EWK_FIND_OPTIONS_WRAP_AROUND;
    3737static const double TOOLTIP_DELAY_SECONDS = 1.0;
     38static const double LONGPRESS_INTERVAL_SECONDS = 1.5;
     39static const double LIST_ITEM_HEIGHT = 24.35;
    3840
    3941#define info(format, args...)       \
     
    5759static Eina_Bool fixed_layout_enabled = EINA_FALSE;
    5860static Eina_Bool separated_process_enabled = EINA_FALSE;
     61static Eina_Bool longpress_enabled = EINA_FALSE;
    5962static int window_width = 800;
    6063static int window_height = 600;
     
    114117        Evas_Object *close_button;
    115118    } search;
     119    struct {
     120        Evas_Object *history_box;
     121        Evas_Object *history_list;
     122        Eina_List *history_list_items;
     123    } history;
    116124    int current_zoom_level;
    117125    Tooltip_Information tooltip;
     
    399407}
    400408
     409static void
     410history_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
    401433static void save_page_contents_callback(Ewk_Page_Contents_Type type, const char *data, void *user_data)
    402434{
     
    506538        if (evas_object_visible_get(window->search.search_bar))
    507539            search_box_hide(window);
     540        else if (evas_object_visible_get(window->history.history_box))
     541            history_list_hide(window);
    508542        else if (elm_win_fullscreen_get(window->elm_window))
    509543            ewk_view_fullscreen_exit(ewk_view);
     
    564598    elm_entry_select_none(window->url_bar);
    565599
     600    if (longpress_enabled)
     601        history_list_hide(window);
    566602    if (ev->button == 1)
    567603        view_focus_set(window, EINA_TRUE);
     
    10131049on_back_button_clicked(void *user_data, Evas_Object *back_button, void *event_info)
    10141050{
     1051    if (longpress_enabled)
     1052        return;
     1053   
    10151054    Browser_Window *window = (Browser_Window *)user_data;
    10161055
     
    10231062on_forward_button_clicked(void *user_data, Evas_Object *forward_button, void *event_info)
    10241063{
     1064    if (longpress_enabled)
     1065        return;
     1066
    10251067    Browser_Window *window = (Browser_Window *)user_data;
    10261068
     
    10811123    info("Stop was Pressed. Aborting load...");
    10821124    ewk_view_stop(window->ewk_view);
     1125}
     1126
     1127static char *
     1128list_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
     1136static void
     1137on_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
     1145static void
     1146navigation_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
     1213static void
     1214on_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
     1222static void
     1223on_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));
    10831229}
    10841230
     
    18141960    window->back_button = create_toolbar_button(window->elm_window, "arrow_left");
    18151961    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);
    18161963    elm_object_disabled_set(window->back_button, EINA_TRUE);
    18171964    evas_object_size_hint_weight_set(window->back_button, 0.0, EVAS_HINT_EXPAND);
     
    18231970    window->forward_button = create_toolbar_button(window->elm_window, "arrow_right");
    18241971    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);
    18251973    elm_object_disabled_set(window->forward_button, EINA_TRUE);
    18261974    evas_object_size_hint_weight_set(window->forward_button, 0.0, EVAS_HINT_EXPAND);
     
    19242072    elm_box_pack_end(window->search.search_bar, window->search.close_button);
    19252073
     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   
    19262086    /* Create ewk_view */
    19272087    Ewk_View_Smart_Class *ewkViewClass = miniBrowserViewSmartClass();
     
    20162176    evas_object_event_callback_add(window->ewk_view, EVAS_CALLBACK_MOUSE_MOVE, on_mouse_move, window);
    20172177    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);
    20182183
    20192184    return window;
Note: See TracChangeset for help on using the changeset viewer.